私はこのようにリフレッシュトークンを手に入れました。それを保つことはできますか?youtube python apiのrefresh_tokenの使い方は?
もしそうなら次回はどうすればブラウザを開く必要はありませんか?
今、私はOAuth2Credentialsオブジェクトを直接作成することを考えていますが、これは正しい方法ですか?
from urllib.parse import urlparse, parse_qs
from oauth2client.client import flow_from_clientsecrets, OAuth2Credentials
from oauth2client.file import Storage
from oauth2client.tools import argparser, run_flow
from apiclient.discovery import build
from apiclient.errors import HttpError
from oauth2client.contrib import gce
import httplib2
import webbrowser
CLIENT_SECRETS_FILE = "bot_credentials.json"
flow = client.flow_from_clientsecrets(
CLIENT_SECRETS_FILE,
scope=scope,
redirect_uri='http://127.0.0.1:65010')
flow.params['include_granted_scopes'] = 'true'
flow.params['access_type'] = 'offline'
auth_uri = flow.step1_get_authorize_url()
webbrowser.open(auth_uri)
url = input('Please enter the redirected url with code')
code = get_url_param(url, 'code')
if code is None:
print('there is an error in your redirect link with code parameter, check if it exists')
exit()
print(code)
credentials = flow.step2_exchange(code[0])
print(credentials.to_json())#refresh_token here!!!
しかし、次に入力する場所は、新しいaccess_tokenを取得するためのトークンをリフレッシュすることですか? – userqwerty1