3

My project is python and using boto3 lib.

I'm using aws cognito Authorization code grant flow with return_type=code instead of return_type=token (implicit flow). Once my user is authorized my redirect url is injected with the queryStringParameter code=4d55a121-8ffc-4058-844b-xxxx.

outlined here

I need to be able to verify this code. Because of course someone can take the redirect url and make a fake code and paste it into the browser. According to this doc I can exchange the code for a token. This works as expected via a rest client. I get the token and can continue to pass the token as the Authorization header. But what I'm asking is there has to be a boto3 method that takes this code and converts it into a token for me. If i have to use the requests lib I will.

I have tried for days. get_user isnt the answer as that requires a token not the code.

For reference on what I'm trying to do heres my repo. The focus is in def edit(). I'm currently using requests to achieve the same thing but would like to use the boto library https://github.com/knittledan/python-lambda-cognito

Ulysse BN
  • 10,116
  • 7
  • 54
  • 82
knittledan
  • 754
  • 2
  • 9
  • 23

1 Answers1

1

Nope, believe you should use an https client to exchange the authorization code for tokens with the token endpoint provided:

https://docs.aws.amazon.com/cognito/latest/developerguide/token-endpoint.html

Jonathan Nikkel
  • 111
  • 1
  • 4