2014-07-27 32 views
0

我正在编写需要使用OAuth 2.0访问Google Spreadsheets的Python 2.7桌面应用程序。我找到了Google Spreadsheets的一个库,用于python here,它使用this python OAuth2.0库。描述为here的桌面应用程序的流程告诉我,我必须首先生成RequestToken URL,用户可以使用它来向应用程序获取授权码。如何为Google API生成RequestToken URL

我已在开发人员控制台中生成客户端ID和客户端密钥。但我无法弄清楚我可以用什么类/方法在python中生成RequestToken URL。

我应该以某种方式自己构建它,还是有API来做到这一点?

回答

0

我从文档here

#!/usr/bin/env python 

import oauth2client 

from oauth2client.client import OAuth2WebServerFlow 

flow = OAuth2WebServerFlow(client_id='your_client_id', 
          client_secret='your_client_secret', 
          scope='https://spreadsheets.google.com/feeds', 
          redirect_uri='urn:ietf:wg:oauth:2.0:oob') 

auth_uri = flow.step1_get_authorize_url() 

print auth_uri 

你会需要自己的client_id虽然client_secret这里想通了。

相关问题