Skip to content

Conversation

@ckng0221
Copy link

@ckng0221 ckng0221 commented Feb 24, 2023

Fixes #22

User can define to use id token or access token in settings.py.
Without defining, it by default take id token.

COGNITO_TOKEN_TYPE = "access"  # '{'id', 'access'} Default: 'id'

The client_id from access token will be validated whether it matches the one defined in the `settings.COGNITO_AUDIENCE`.
When using access token, the backend will call the userinfo endpoint from Amazon Cognito, to obtain the user info based on the access key, and pass into the payload inside the Django user_model's get_or_create_for_cognito method.
Split the method into get_user and create_for_cognito.
Spliting the method into two allows more efficient calling of the method, especially  when using access token.
The get_user method will first check whether the user exists. If exists, it will directly skip the get requests from UserInfo endpoint, and also skip the attempt for user creation, and directly return the user object.

The UserInfo endpoint will be only called during the initial registeration of the client that does not exist in User database.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to accept Cognito Access Tokens

1 participant