Is user_id that is given by Jira in request to addon unique?

Hi,
i know that every user has long accountId that is unique, but is it safe to use user_id (for example “admin”) and host url (for example “someStuff.atlassian.net”) as user identifier? Is that user name unique inside one Jira instance?

Username and userkey are deprecated in favor of accountId. You shouldn’t depend on them because they will be completely removed very soon.

See here:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302#api-rest-api-3-user-get

And here:

https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/

2 Likes

It’s definitely not safe, as user keys and usernames are being entirely removed from Jira cloud and will be gone within weeks.

1 Like

Ok, i got it. Does that means that i need to use accoundID to get bearer jwt token for user? If yes, so where from should i get accountId if i can’t use user_id or user_key?
Now i get user name and host url from request params (of course after verifying qsh and jwt).

Yes, you need to use and accountId. How you get the bearer token depends on the library you are using (e.g. Atlassian Connect Express) but all these libraries now expect an accountId.
You receive the accountId of the current user in the rest call Jira makes to your app (e.g. in a post-function) and if you need it from your UI you can use the JavaScript API to get the accountId of the current user and send it to your server code in your rest calls. Or of course use it directly from your browser side code.

2 Likes

Ok, thanks for reply. I will look through that places you mentioned.

Upd: accoundId is sent in jwt token.