Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing required parameter: refresh_token #102

Closed
blohinn opened this issue Dec 22, 2017 · 2 comments
Closed

Missing required parameter: refresh_token #102

blohinn opened this issue Dec 22, 2017 · 2 comments

Comments

@blohinn
Copy link

blohinn commented Dec 22, 2017

I have a custom backend. All works fine, but i have problem when token was expired...
What about refresh token? I didnt find anything about this problem...

Custom backend:

class MongoBackend(BaseBackend):
    def get(self, blueprint):
        from ..collections import users_collection
        try:
            user = users_collection.find_one({'_id': ObjectId(current_user.id), 'oauth.provider': 'google'})
            return user['oauth']['token']
        except:
            return None

    def set(self, blueprint, token):
        from ..collections import users_collection
        users_collection.update_one({'_id': ObjectId(current_user.id)}, {'$set': {'oauth.token': token}})

    def delete(self, blueprint):
        from ..collections import users_collection
        users_collection.update_one({'_id': ObjectId(current_user.id), 'oauth': {'$set': {'token': ''}}})  # i know that didnt work
        return None

User scheme:

{
    "_id" : ObjectId("5a3d489ecefa5b3ad0b77b46"),
    "email" : "blablabla@gmail.com",
    "oauth" : {
        "provider" : "google",
        "token" : {
            "access_token" : "bla bla bla",
            "expires_in" : 3420,
            "id_token" : "bla bla bla",
            "token_type" : "Bearer",
            "expires_at" : 1510969326.18578
        }
    }
}

When token was expired i see:
oauthlib.oauth2.rfc6749.errors.InvalidClientIdError
oauthlib.oauth2.rfc6749.errors.InvalidClientIdError: (invalid_request) Missing required parameter: refresh_token

@blohinn
Copy link
Author

blohinn commented Dec 22, 2017

Ohhh..
Solution:

google_blueprint = make_google_blueprint(
    client_id='',
    client_secret='',
    scope=['profile', 'email'],
    offline=True
)

offline=True fix my problem..
Man you make awesome lib, but why you didnt write about this trick? Or you wrote, but I didnt find?

@blohinn blohinn closed this as completed Dec 22, 2017
@singingwolfboy
Copy link
Owner

@blohinn It’s documented here: http://flask-dance.readthedocs.io/en/latest/providers.html#module-flask_dance.contrib.google

Is there a better place to document this? I’d really appreciate it if you could make a pull request to improve the documentation, rather than just criticizing it!

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

No branches or pull requests

2 participants