Hi,
I was trying to access the API via the postman. I see an error of the token.
I have the token I generated from Stuart’s sandbox account.
I’m trying to find out how to pass this token? Is it in header that you pass the token?
Hi,
I was trying to access the API via the postman. I see an error of the token.
I have the token I generated from Stuart’s sandbox account.
I’m trying to find out how to pass this token? Is it in header that you pass the token?
Hi @bbilal,
As you are receiving a 401 error this indicates the 30-day expiration time of your access token has passed
I would recommend following step 7 from our post here - Public Postman Collection Now Available.
The method above places the authorisation header in all child folders and endpoints used.
You can also use our Get Ouath access token endpoint to generate a new token.
I hope this helps & please let us know if you require any further assistance.
Kind regards
Where am I supposed to get the following information:
oauth_client_id
oauth_client_secret
api key
Hi @bbilal,
Your client ID and client secret found on your Stuart dashboard.
Client ID = oauth_client_id
Client Secret = oauth_client_secret
As described in the steps of the public postman collection post attached above, the client ID and client secret is required to generate a new access token for your account.
Hi @bbilal Thank you for the image,
The variable “h2h_api_key” can be ignored for now as this is would be your API key for our hub to home API.
It looks like you have setup your Postman environment correctly, now to generate a new token the easiest method would be to click on the “Stuart on-demand” folder, this would then open the authorisation section as shown below.
Scroll to the bottom of the page and click the “Get New Access Token” button to automatically generate a new token from the client ID and secret in your environment.
Just a suggestion to other developers that may be getting issues with expired tokens. - This is how I have handled it:
Firstly store your token in a data store somewhere in your application (securely of course)
In your code, before you try and use your token validate that it works first.
Do this by attempting to validate a “fake job”.
If the http response you get is Unauthorized, it’s not valid. So create a new one via the API.
Then update your datastore with your new token, that way you don’t have to worry about updating it manually or trying to use a date to work out if you need to update it or not.