0
0

GoogleのOAuth2の実装時にリフレッシュトークンが必要になり、access_type=offlineを設定するだけだとAPIから帰ってこないケースがあったのでその時の解決方法を備忘録で残しておく。

結論から言うと、prompt=consentをさらにリンクに付け足す必要があった。

prompt=forceを設定する方法を紹介する記事も見かけたが、仕様変更なのか自分が試したときはinvalidになってしまったので注意(2024/07/05時点)。

全体URLはこんな感じ。

https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope=openid email profile&access_type=offline&prompt=consent

※以下の記事が詳しい
https://www.eisbahn.jp/yoichiro/2012/05/google_oauth2_web_server_profile_refreshtoken.html#gsc.tab=0

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0