Generate API tokens for multiple customers in a single query using GraphQL
search cancel

Generate API tokens for multiple customers in a single query using GraphQL

book

Article ID: 428287

calendar_today

Updated On:

Products

CloudHealth

Issue/Introduction

GraphQL documentation details how partners can generate an API token for their channel customers using the Client API ID. 

https://help.cloudhealthtech.com/graphql-api/#generate-an-api-token-using-the-client-api-id

 

SAMPLE REQUEST

mutation {
getAccessToken(input: {
  refreshToken: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  customer: "crn:<partner_tenant_id>:msp_client/<msp_client_id>",
  justification: "Justification text"
}){
  accessToken
  refreshToken
  }
}

 

This query allows the partner to generate and API token for only one customer at a time.

Resolution

Partners can generate API tokens for multiple channel customers by using a modified version of this query using aliases.

 
mutation {

Alias1getAccessToken(input: {

  refreshToken"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

  customer"crn:<partner_tenant_id>:msp_client/<api_client_id>"

  justification"Justification text"

}){

  accessToken

  refreshToken

  }

  Alias2getAccessToken(input: {

  refreshToken: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

  customer: "crn:<partner_tenant_id>:msp_client/<api_client_id>"

  justification: "Justification text"

}){

  accessToken

  refreshToken

}

  Alias3getAccessToken(input: {

  refreshToken: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

  customer: "crn:<partner_tenant_id>:msp_client/<api_client_id>"

  justification: "Justification text"

}){

  accessToken

  refreshToken

}

}
 
 

This query sample uses aliases to individually get the API tokens for each customer. Aliases are user-defined and can be named anything the user prefers.

 

Alias naming examples:

  • Customer1, Customer2, Customer3
  • CustomerName, CustomerName, CustomerName
  • Alias1, Alias2, Alias3