IARI
IARI

Reputation: 1377

gdata python: store OAuth2Token

I am writing an app that is supposed to work with Google contacts. So at some point I do the authentication with OAuth2:

token = OAuth2Token(client_id=client_info["client_id"],
                    client_secret=client_info["client_secret"],
                    scope=CLIENT_SCOPE,
                    user_agent=USER_AGENT)

# I open a webserver and browser until I retrieve the 
# Auth code in a variable named "code"

token.get_access_token(code)

As of now, this flow starts every time the app accesses contatcs. How do i make my application remember the authentication?

Does it have to do with refresh tokens, and if so, how does that works?

Upvotes: 0

Views: 60

Answers (1)

nvnagr
nvnagr

Reputation: 2063

Yes, you should save the refresh token (depending on your system configuration) that is exchanged using the code.. Next time the script runs, it should look for the refresh token first and should try to use it. If it doesn't find it or the refresh token doesn't work, it should try to get the new code.

Upvotes: 2

Related Questions