Google ディレクトリ サービス API で更新トークンを使用する方法はありますか? その方法の例が見つかりませんでした (私は Python を使用しています)。以前に設定された資格情報を使用して、次のコードに似たものを探しています (これは Google Adwords API で機能します)。
oauth2_client = oauth2.GoogleRefreshTokenClient(
CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN)
adwords_client = adwords.AdWordsClient(
DEVELOPER_TOKEN, oauth2_client, USER_AGENT, CLIENT_CUSTOMER_ID)
self.managed_customer_service = adwords_client.GetService(
'ManagedCustomerService', version='v201402')
Directory API については、次のコード スニペットだけを見つけましたが、更新トークンを使用する方法がわかりません。
flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, REDIRECT_URI)
authorize_url = flow.step1_get_authorize_url()
print 'Go to the following link in your browser: ' + authorize_url
code = raw_input('Enter verification code: ').strip()
credentials = flow.step2_exchange(code)
# Create an httplib2.Http object and authorize it with our credentials
http = httplib2.Http()
http = credentials.authorize(http)
self.directory_service = build('admin', 'directory_v1', http=http)
私の最終的な目標は、更新トークンだけを使用してアプリケーションを承認し、ブラウザーを開いたり、ログインしたり、毎回新しいトークンを取得したりする必要がないことです。