Google スプレッドシート API に対して承認済みのリクエストを作成しようとしています。私が見つけたすべての例では、ユーザーからのメールとパスワードをリクエストしています。
- http://www.payne.org/index.php/Reading_Google_Spreadsheets_in_Python
- http://www.mattcutts.com/blog/write-google-spreadsheet-from-python/
- http://mrwoof.tumblr.com/post/1004514567/using-google-python-api-to-get-rows-from-a-google
さて、この問題は Google が実装する OAuth2 プロトコルで解決されました。OAuth2 プロセスを経て、有効な access_token を取得しました。これを使用して、Google ドライブをスムーズに操作できます。
access_token = get_access_token() # external function
user_agent = request.META['HTTP_USER_AGENT']
credentials = AccessTokenCredentials(access_token, user_agent)
http = httplib2.Http()
http = credentials.authorize(http)
service = build('drive', 'v2', http)
service.files().copy(fileId=k, body=dict(title="Copia")).execute() # this works!
しかし、access_token を使用してスプレッドシート API を操作する方法がわかりません。まだ電子メールとパスワードのログインを使用していますか?
ありがとう!
PS: ところで、私は python gdata パッケージを使用しています。良いリファレンスがあれば教えてください! :)