How can I retrieve my email,domainname,api token in a app which am integrating with jira?

Harshit Somani January 17, 2021

I am making an integration app with jira,I want to retieve 3 details of my account(domain name,email,api token) within that app,I am using python flask to make that app,can you please help me with this?

1 answer

1 accepted

1 vote
Answer accepted
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 17, 2021

Hi @Harshit Somani 

Have you gotten pass the authentication system to enable connect with an instance? 

Harshit Somani January 18, 2021

whats that I didn't understand?
I didnt make any progressive steps in this issue,can you explain in detail?
Thankyou

Harshit Somani January 18, 2021
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2021

Hey @Harshit Somani 

If you're integrating using flask, especially when creating a connect app. It's either you create with direct REST API using email and token or you use JWT (recommended).Take note that if you're using JWT, you won't have access to email addresses, you need a special API upon approval by Atlassian to be able to access such. However with direct API you can query those.

So my question is, were you able to at least connect to one of the API? Is only if you can do that, then you can retrieve information about the user or any user on the instance. 

Harshit Somani January 19, 2021

https://docs.google.com/document/d/1GC9fSC61BtWhdoTLBZTHxUsNmPiY2wMmzT5OqvQuY80/edit?usp=sharing

@Prince Nyeche  Can you look at my python code so that you will get clear understanding of it.Thankyou

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2021

Hi @Harshit Somani 

Please can you put the codes on Github and remove any sensitive information from it, then share the link. I will have a look at it. currently, I think the docs you share might contain sensitive information.

Harshit Somani January 19, 2021

Hai @Prince Nyeche 

Here is the link for my repository of my program in github,it dosent contain any sensitive information

https://github.com/HARSHIT-SOMANI/code.git

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2021

Hi @Harshit Somani 

I believe with flask_atlassian_connect library, which uses JWT from what I read, you need to create a Client class. That Client class will have access to some fields such as baseurl, sharedsecret and clientkey which needs to be dynamically pulled, so an authentication can be created which can then be used to query the Jira endpoints.

From the code, is seems you want to collect some user input from forms which will then be posted to one of Atlassian's endpoint. Also, you shouldn't make two routes with the same paths e.g. @app.route('/') - this is confusing to flask. Your Atlassian descriptor file has JWT as none. do you just want to authenticate to Jira via REST API only or do you want to use JWT still? As the latter is much difficult to implement given what you want to insert.

If you simply just want REST API connection with email and api token to Jira. you can easily do that with the requests library or specifically to Jira cloud - you can use this library jiraone made by me and you can call endpoints directly.

basic usage is shown on the above link. you can integrate it directly to any Flask App. e.g.

 

from jiraone import LOGIN, endpoint
from flask import request, render_template, Flask

app = Flask(__name__)


@app.route("/index", methods=["GET", "POST"])
def index():
data = None
user = ""
token = ""
link = "http://example.atlassian.net"
LOGIN(user=email, password=token, url=link)
if request.method == "GET":
data = LOGIN.get(endpoint.myself()).json()
# some other expression here to has
return render_template("index.html", data=data)


if __name__ == "__main__":
app.run()

 let me know if we're on the same page now? And how I can help further.

Harshit Somani January 20, 2021

Hai @Prince Nyeche ,Am afraid my main query has not been answered

My main question is how can we fetch the fields called ('email','token','link') without manually typing them,according to the code you are asking to manually type these fields,how can we fetch them just by using code

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2021

Hi @Harshit Somani 

That's why I asked, if you want to use JWT. This is a much complex approach. The module you used flask_atlassian_connect can do that but understanding JWT is a bit complicated. Here's a module for atlassian_connect_jwt which explains how you can use it with python. Also, here's a quick explanation on JWT. However with JWT, you cannot fetch email addresses just like that, you require an Atlassian Approved API to query email addresses.

However, in order to understand your use case here, what exactly do you want to achieve with your add-on? Is your add-on suppose to impersonate any user to submit or make request?  Please explain more on your use case, so i can get a clearer picture. Thanks

Harshit Somani January 20, 2021

hai @Prince Nyeche 

My add on will add some devices as assets to the jira instance,I am following the procedure mentioned in the tab called "add assets via rest endpoint",there the user who installed my add-on will be needing my domainname,email and token.Instead of manually typing these fields I want to automate this process so that who ever installs my add-on will need not have to enter these fields manually when they want to add assets

Harshit Somani January 20, 2021
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 21, 2021

Looking at that requirement you need to use JWT in your connection to do what you want. the example given is just to demonstrate the possibility.

Connect apps have HTTPS and JWT authentication built in to secure communication between your app, Jira, and the user. Our Connect toolkits, Atlassian Connect Express (ACE) and Atlassian Connect for Spring Boot, handle most of the security setup for new apps. Note that OAuth 2.0 (3LO) isn't supported for Connect apps.

This is what is explained under the overview for Atlassian connect.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events