Reputation: 261
I am looking for a way to generate token using login/password on reportportal. Pretty sure, there should be a way using a API call. I am just not able to find it.
So given, (project name, user, password), I should get a token that I can use for making other API calls.
Thanks.
Upvotes: 2
Views: 3744
Reputation: 31
Make a post to:
/uat/sso/oauth/token?grant_type=password&password=***password***&username=***username***
Set basic authentication with credentials (username: ui and password: uiman) to get the accesstoken for scope UI, use this token to fetch apitoken.
Upvotes: 3
Reputation: 420
Before getting API token, you have to generate it.
If it's already generated (you have logged in with this user), this endpoint will return you existing API token:
GET
/sso/me/apitoken
Example:
curl -X GET --header 'Accept: application/json' --header 'Authorization: bearer 4f73871b-e477-4f49-b1bd-805b24201fe0' 'http://web.demo.reportportal.io/uat/sso/me/apitoken'
Response:
{
"access_token": "b1debc0a-d47d-492f-aa7c-3e2e0fb96332",
"token_type": "bearer",
"scope": "api"
}
Pay attention, that bearer in 1st (curl) request has scope UI
and bearer in response has scope API
.
** If GET
requests returns you error, then you need to generate token.
POST
sso/me/apitoken
Example:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: bearer 4f73871b-e477-4f49-b1bd-805b24201fe0' 'http://web.demo.reportportal.io/uat/sso/me/apitoken?authenticated=true'
Response:
{
"access_token": "4e76e31e-0250-4e5e-ba66-90105dd014bb",
"token_type": "bearer",
"scope": "api"
}
(!) Tokens are public. Used from public account at demo instance http://web.demo.reportportal.io
Upvotes: 3