Bitbucket-Server: get username using header #39278
RahulGautamSingh
started this conversation in
Suggest an Idea
Replies: 1 comment
-
Probably this wasn't broadly known back then but there is an endpoint for this since around BitBucket Server v3.x: Perhaps the suggestion to use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Tell us more.
Currently, when we configure a bitbucket-server using a token, we do fetch username attached to the token. I am not sure if a username is always present for a token or not .. I'll need to verify that.
We don't fetch the username like we do on other platforms because there is no dedicated api endpoint for it.
There seems to be a way to get the username thought by adding the header:
X-AUSERNAMEto any request that we make to the bitbucket-server API. 1The suggested way is to call the
/rest/api/1.0/application-propertiesendpoint which never fails and attach the header with it to get user details related to the token from the response.In the bitbucket-server code we conditionally make the request to
application-propertiesendpoint here:renovate/lib/modules/platform/bitbucket-server/index.ts
Lines 129 to 139 in 84633f1
I think we should remove the condition and always make this call with the required header, so we can fetch
username..except for the rare case whenusernameis already configures andenv.RENOVATE_X_PLATFORM_VERSIONis also set.Footnotes
https://community.developer.atlassian.com/t/obtain-authorised-users-username-from-api/24422 ↩
Beta Was this translation helpful? Give feedback.
All reactions