1

I need to call the method of @oauth.token_handler internally from flask. The signature is as follow:

@oauth.token_handler
def access_token(*args, **kwargs):
    return None

So it calls internally the implementation of token_handler(). I try to call

response = access_token("", {'grant_type':'password'})

Wishing that oauth can retrieve the arguments in the method, but it doesn't work.

400 {"error": "unsupported_grant_type"}

Oauth don't find the data (without surprise for me)

When a curl method work as expected:

curl -k -X POST -d "client_id=f9O7kapzXnK1gYAxxxxxxx&grant_type=password&username=blah&password=pass" http://localhost:5001/oauth/token

My question is, how to fake this call to oauth internally in order that it can retrieve all the information (grant_type, client_id, etc...). Because for the moment, I tryed with no luck.

Note: I know oauth should be called from the client side; But here, the process is that a person send me his/her provider credential for his/her id profil, I check if the credential is ok, and then I create an internal account with my own oauth provider and send them the access_token to the ressource of my application. My problem here is that I don't know how to call access_token() with the right parameter. Flask-oauth can't find my arguments.

Doc can be found here: http://flask-oauthlib.readthedocs.io/en/latest/api.html

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Mr Bonjour
  • 3,330
  • 2
  • 23
  • 46

1 Answers1

0

I'm the author of Flask-OAuthlib. I have to say, it is not well designed, I strongly suggest that you use Authlib. Here is an example of OAuth 2 provider.

lepture
  • 2,307
  • 16
  • 18