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?
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.
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"])
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__":
let me know if we're on the same page now? And how I can help further.
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
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
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
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.
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event