Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

標準で対応していないソーシャルログインへの対応 #5

Closed
takeyuweb opened this issue Feb 17, 2018 · 1 comment
Closed

Comments

@takeyuweb
Copy link
Owner

takeyuweb commented Feb 17, 2018

Yahoo! JAPAN

https://auth0.com/docs/extensions/custom-social-extensions

@takeyuweb
Copy link
Owner Author

takeyuweb commented Feb 24, 2018

CustomSocialExtensionを使う

ドキュメントどおり NEW CONNECTION から作成

Yahoo! JAPANデベロッパーネットワークでアプリケーションを登録
https://e.developer.yahoo.co.jp/dashboard/

App

コールバック URL

https://xxxxxxxxxx.auth0.com/login/callback

New Connection

Client ID, Client Secret

先に作成したアプリケーションの詳細ページに記載されている情報をそれぞれコピペ

Authorization URL

https://auth.login.yahoo.co.jp/yconnect/v2/authorization

Token URL

https://auth.login.yahoo.co.jp/yconnect/v2/token

Scope

openid email など
属性取得API(UserInfoAPI)を参考に

Fetch User Profile Script

ドキュメントと他のカスタムコネクションを参考に

属性取得API(UserInfoAPI)

function(accessToken, ctx, cb) {

  request.get('https://userinfo.yahooapis.jp/yconnect/v2/attribute', {
      headers: {
        'Authorization': 'Bearer ' + accessToken,
      },
      json: true
    },

    function(e, r, profile) {
      if (e) return cb(e);
      if (r.statusCode !== 200) return cb(new Error('StatusCode: ' + r.statusCode));
      profile.user_id = profile.sub;
      cb(null, profile);
    });
}

使い方

ここまで設定してCustom Social Connectionsに作成したコネクションが追加されているので、有効化すればAuth0のログインフォームに追加されている。

screenshot from 2018-02-24 22-27-43

screenshot from 2018-02-24 22-28-57

UID

omniauth-auth0の応答はこんな感じです

userinfo: {"provider"=>"auth0", "uid"=>"oauth2|YahooJAPAN|XXXXXXXXXXXXXXXXXXXXXXX", ...

すでにomniauth-auth0 を導入できている場合、特にサーバアプリケーション側の変更は不要

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant