A token is basically a passport, it has information about the user, like the name, email, certificate origin (AWS, Google, etc), it has an expiration date, etc. This "passport" in the form of a long encoded token is the way we communicate with Hasura and the AWS API Gateway.
Hasura needs the token to know the roles of the user, and makes sure this token is valid by checking with AWS directly. The case is the same with AWS API Gateway, but the only difference is that we make the validation ourselves in the API.
To pass this token, we use the standard HTTP header Authorization , much like this:
Authorization: Bearer <TOKEN STRING HERE>
Tokens are currently programed to expire after one hour of use.
Not all Tokens are Created Equal
There are two types of tokens, AWS Cognito tokens and Single Sign-On. With these two types of tokens, there are two different environments: 1) Local/staging and 2) Production.
The main difference between the cognito token and the Single Sign-On is in the contents of the token, the SSO token is longer and has more information about Active Directory.
1) Local/Staging. The tokens for local/staging only work for local or staging use. This is true for the local/staging hasura, or local/staging API (flask app).
2) Production. The tokens for production, only work for the production hasura instance or the API.
Where can I find it?
Log in to Moped (if you need access to local/staging) launch the local instance or log in to the staging moped instance.
Once logged in, in Chrome find the developer console:
The decoded token looks like this, from this example, you can see this is a Single Sign-On token, given the extra identity details related to Microsoft AzureAD: