You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Authenticate

Xray itself provides a REST API with endpoints specifically made for dealing with test management.
Requests made to Xray's REST API must be authenticated using a client id and a client secret, which in turn are based on an API Key created for some user in Xray Global Settings: API Keys global settings.
Thus, the first step you need to do is obtaining a token based on the Client Id and Client Secret of your assigned API Key. From thereon, you can use it to make whatever requests to Xray Cloud.


Authenticates the requester based on the provided Client Id and Client Secret and returns an authorization token to be used in other API requests.

Request

Example



Authentication JSON
{ "client_id": "32A27E69B0AC4E539C1401643799E8E7","client_secret": "d62f81eb9ed859e11e54356dd8a00e4a5f0d0c2a2b52340776f6c7d6d757b962" }



Example Requests

curl -H "Content-Type: application/json" -X POST --data @"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v1/authenticate

curl -H "Content-Type: application/json" -X POST --data '{ "client_id": "32A27E69B0AC4E539C1401643799E8E7","client_secret": "d62f81eb9ed859e11e54356dd8a00e4a5f0d0c2a2b52340776f6c7d6d757b962" }'  https://xray.cloud.xpand-it.com/api/v1/authenticate

# the following example, shows a way of setting a shell variable with the token value, so it can be used in subsequent requests

token=$(curl -H "Content-Type: application/json" -X POST --data @"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v1/authenticate| tr -d '"')

Responses

200 OK : application/json : Successful. Returns a JSON string (delimited with the " character), containing the authorization token.

Example Output
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnQiOiI0MjZiYzA4Yy02N2VmLTNjMjYtYWU1YS03NjczYTA1ZjIwNjkiLCJ1c2VyS2V5IjoiYW5kcmUucm9kcmlndWVzIiwiaWF0IjoxNTI1ODcxODkzLCJleHAiOjE1MjU5NTgyOTMsImF1ZCI6IjMyQTI3RTY5QjBBQzRFNTM5QzE0MDE2NDM3OTlFOEU3IiwiaXNzIjoiY29tLnhwYW5kaXQueHJheSIsInN1YiI6IjMyQTI3RTY5QjBBQzRFNTM5QzE0MDE2NDM3OTlFOEU3In0.8ah2IQ9rA_zotyh_6trFgfIvhn2awdFFrOHnN2F2H7o"

400 BAD_REQUEST : text/plain : Wrong request syntax.

401 UNAUTHORIZED : text/plain : The Xray license is not valid.

500  INTERNAL SERVER ERROR : text/plain : An internal error occurred when authenticating the request.

  • No labels