Comment on page
API and Authentication
The
Id
is the base64-encoded version of the databaseId
with the ObjectType. In other words,
Id
= ObjectType
+ :
+ databaseId
For example, if the
databaseId
for a recipe is b78a8f0d-4c89-4df1-bc73-42e2175e2737 then its iD would be UmVjaXBlOmI3OGE4ZjBkLTRjODktNGRmMS1iYzczLTQyZTIxNzVlMjczNw==In Python, this would be done as follows:
base64.b64encode(b"Recipe:b78a8f0d-4c89-4df1-bc73-42e2175e2737")
Use the
databaseID
to execute some of the queries and mutations. The databaseID
parameter is the base64-encoded version of the ID of an element that can be either of a user or a recipe. For that reason, use the
databaseId
to send it as a sg-user
parameter in the header. {
"Authorization": "Token replace_user_token",
"sg-user": "c975dac5-4d23-b348-cb30-ec50b33c4f91"
}
Include the
databaseID
in the sg-user
for all the queries that are executed on behalf of a user. For example:Using it in the header:
- If you need to get the list of all users created with a specific token, it is only required to send the token parameter because we don't require to get the information of a specific user.
- If you need to generate a meal plan, it is required to send the
databaseID
in the header since it will be generated for a specific user.
Use it in a mutation:
- If you need to update your own recipe, you will need to pass the
databaseID
as a parameter on theupdateOwnRecipe
mutation.
Use the ID when you The ID is the base64-encoded version of the
databaseId
. Use this ID to send it as a parameter within a query or a mutation.Some common examples:
The JWT authentication is intended to be used on the client-side while the API token authentication must be only used on the server-side.
Partners/clients which have an isolated database will need to authenticate by using a different HTTP header named
Suggestic-Partner.
Last modified 11mo ago