Search code examples
pythonoauthflaskoauth-2.0oauth2client

Python library that supports setting oauth response_type


The server I am working with does not support code as a response type. I attempted to use flask-oauth but it does not support setting a response type. I was wondering whether it was possible to configure flask-oauth to change it to token. I have tried doing it by setting:

request_token_params = {'response_type': 'token', 'scope':'read'}

But I get the error

prepare_grant_uri() got multiple values for keyword argument 'response_type'

If not, does anyone know a python library that supports oauth2 and setting the response type.


Solution

  • I ended up using requests-oauthlib to get the functionality I was looking for. You can use the MobileApplicationClient from oauthlib and pass it to the Oauth2Session. Here's an example:

    from oauthlib.oauth2 import MobileApplicationClient
    from requests_oauthlib import OAuth2Session
    mobile = MobileApplicationClient(client_id)
    s = OAuth2Session(client=mobile)