Authentication to the VMware Tanzu GraphQL API requires a TCSP user token that is scoped to an Tanzu Hub role. See
The authMutation
mutation has a method to generate an access token, which is used in subsequent API Queries to authenticate.
|
|
The response to the authMutation
method is a JSON payload with the properties requested from the
|
|
The authorization
field is a Bearer token that is then added to subsequent queries as the Authorization
header. The expirationTime
field is a UTC ISO-8601 formatted timestamp of the expiry time for the authorization
. Note: there’s also an accessToken
property that contains a JWT access token, but that is not requested in this example.
The same query can be executed using cURL
via the command line. Note that the --data-binary
payload must be structured with escaped newlines (\n
).
curl 'https://api.platform.tanzu.broadcom.com/hub/graphql' \n
-H 'Content-Type: application/json' \n
-H 'Accept: application/json' \n
--data-binary '{"query":"mutation($TANZU_USER_TOKEN: String!) {\n authMutation {\n generateAccessToken(userToken: $TANZU_USER_TOKEN) {\n authorization\n expirationTime\n }\n }\n}","variables":{"TANZU_USER_TOKEN":"_t9YqUHLn..<snip>..MgtqnTzjxS"}}'