LoginSignup
16
15

More than 5 years have passed since last update.

omniauth-twitterでemail情報を取得する

Posted at

omniauth-twitterのレスポンス例を確認したところ、あれれ〜emailなんてどこにも書いてないよぅ。

email情報がどうしても取得したかったので調べるとTwitter Developer Documentationにこんな記述がありました。

The “Request email addresses from users” checkbox is available under the app permissions on apps.twitter.com. Privacy Policy URL and Terms of Service URL fields must be completed in the app settings in order for email address access to function. If enabled, users will be informed via the oauth/authorize dialog that your app can access their email address.

以下、私的スーパー簡易翻訳

ユーザーのemail情報が欲しくば、Privacy Policy URLTerms of Service URLを設定せよ。そうすれば道は開かれるであろう。

設定してみた。

Kobito.ACIMEc.png

そして上記記述の通りPermissionsを確認するとこんな欄が。

Kobito.HK52nJ.png

チェックをつけてUpdate SettingsするとSuccessfully!OK、そういうことだったか。

Kobito.lL6WAz.png

これでレスポンスにemailが含まれるようになった。問題は解決した。

レスポンス例

{
  :provider => "twitter",
  :uid => "123456",
  :info => {
    :email => "oauth@example.com"
    // 以下略

だがここでふと思い立ち、Privacy Policy URLTerms of Service URLを消した状態でPermissions を確認してみた。(下図がその様子)そう、Request email addresses from usersは初めからずぅぅぅぅぅっと表示されていた。そう見落としていたのだ。

Kobito.q7otId.png

この状態でチェックをつけてUpdate Settingsするとなんだか見覚えのあるエラーメッセージが表示された。

Kobito.Pvuv0a.png

そう見落としていたのだ。見落としていたのだ。

1時間モッタイナイ!

16
15
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
16
15