APIs & Services
Authentication
API authentication
3min
this guide will teach you how to generate an access token and how to make a request to an altrata graphql api endpoint generating an access token the access token is a string which contains the credentials and permissions that can be used to access a given resource how to generate the access token to generate an access token, you will need to make a http post request to https //api auth altrata com/oauth2/token https //api auth altrata com/oauth2/token in the request, you will need to specify the following property parameter value description grant type query 'client credentials" the oauth2 grant type that is used to obtain an access token x api key header yourapikey you will need to enter your assigned api key as the value authorization header username\ password basic auth is used for the authorization if you are making a request via curl, you can supply your username\ password if you are using a backend language/framework such as node js, you will need to ensure that your username and password is base64 encoded when making a request to obtain an access token see the node js example on the right to see how to potentially base64 encode your credentials once you have made a successful request to obtain an access token, you will get back a 200 response code that contains your bearer access token { "access token" "youraccesstoken", "expires in" 28800, "token type" "bearer" } the token is a json web token the expiration time for the tokens is set at 28800 seconds which is the equivalent of 8 hours once 8 hours has passed, the token will have expired and you will need to request a new token please note that if you request a new token before the 8 hours have passed on your existing access token, you will be issued with a new token that will terminate your previous token this means that you will not be able to use your previous access tokens to make calls to any altrata api store your access token in a secure location authenticating to use graphql endpoint now that you have generated an access token, you will need to do the following to to access the graphql endpoint if you are unsure of a graphql url for a service(s), please visit the services docid 3rgzmf5uh3ep0bh4snvm0 page that outlines all urls set your http method to be a post request set the url to be the graphql endpoint that you wish to make a request to include both x api key and authorization header provide your api key as the value in the x api key header, and set the value bearer and include your access token for the authorization header