Python 如何为Google API生成RequestToken URL

Python 如何为Google API生成RequestToken URL,python,oauth-2.0,google-api,google-api-python-client,Python,Oauth 2.0,Google Api,Google Api Python Client,我正在编写Python 2.7桌面应用程序,它需要使用OAuth 2.0访问Google电子表格。我找到了一个使用python OAuth2.0库的Google Spreadsheets for python库。描述的桌面应用程序流程告诉我,我必须首先生成RequestToken URL,用户可以使用该URL获取应用程序的授权代码 我已经在开发人员控制台中生成了客户端ID和客户端机密。但我不知道在python中可以使用什么类/方法来生成RequestTokenURL 我应该自己构造它还是有API

我正在编写Python 2.7桌面应用程序,它需要使用OAuth 2.0访问Google电子表格。我找到了一个使用python OAuth2.0库的Google Spreadsheets for python库。描述的桌面应用程序流程告诉我,我必须首先生成RequestToken URL,用户可以使用该URL获取应用程序的授权代码

我已经在开发人员控制台中生成了客户端ID和客户端机密。但我不知道在python中可以使用什么类/方法来生成RequestTokenURL


我应该自己构造它还是有API来实现它?

我已经从文档中找到了答案

不过你需要你自己的客户id和客户机密

#!/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