Gmailを覗くため前に必要なトークン取得

トークン取得

curl -d client_id={OAuthのクライアントID} -d client_secret={OAuthのクライアントシークレット} -d redirect_uri=urn:ietf:wg:oauth:2.0:oob -d grant_type=authorization_code -d code={quickstart.pyで取得したコード} https://accounts.google.com/o/oauth2/token



リフレッシュトークンからアクセストークンを取得

取得したトークンは30分で無効になるのでリフレッシュトークンからアクセストークンを取得する必要がある

curl -d "client_id={OAuthのクライアントID}&client_secret={OAuthのクライアントシークレット}&refresh_token={トークン取得時に取ったrefresh_token}&grant_type=refresh_token" https://accounts.google.com/o/oauth2/token