仅使用auth_令牌或refresh_令牌通过Google Python SDK进行身份验证

仅使用auth_令牌或refresh_令牌通过Google Python SDK进行身份验证,python,authentication,oauth-2.0,google-api,google-oauth,Python,Authentication,Oauth 2.0,Google Api,Google Oauth,我有一堆gmail.storage文件,其中包含一个JSON blob,其中包含用户帐户的访问信息。我使用PHP获取这些凭据集,以提示用户对我的应用进行身份验证/授权。我能够使用这些凭据调用Gmail API。JSON包含以下字段: {"access_token": xxxxxx, "token_type":"Bearer", "expires_in":3599, "refresh_token":"xxxxxx", "created":1421545394} 但是,当我使用PythonSDK

我有一堆gmail.storage文件,其中包含一个JSON blob,其中包含用户帐户的访问信息。我使用PHP获取这些凭据集,以提示用户对我的应用进行身份验证/授权。我能够使用这些凭据调用Gmail API。JSON包含以下字段:

{"access_token": xxxxxx,
"token_type":"Bearer",
"expires_in":3599,
"refresh_token":"xxxxxx",
"created":1421545394}
但是,当我使用PythonSDK for Gmail使用以下凭据文件对调用进行身份验证时:

 credentials = storage.get()

它说它需要字段
\u module
\u class
和其他一些字段。当我使用Python获取信息时,我能够获得这些信息,但不能使用PHP。你知道如何使用上面的代码在没有这些无关字段的情况下获取凭据吗?

在再次使用凭据之前,只需调用刷新方法

storage = file.Storage("auth.dat")
credentials = storage.get()

http = httplib2.Http()
credentials.refresh(http)   # <----------
http = credentials.authorize(http)

service = build('whatever_service', 'v2', http=http)
storage=file.storage(“auth.dat”)
凭据=存储。获取()
http=httplib2.http()
凭据刷新(http)#