標準で対応していないソーシャルログインへの対応
takeyuweb opened this issue · 1 comments
takeyuweb commented
takeyuweb commented
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
ドキュメントと他のカスタムコネクションを参考に
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のログインフォームに追加されている。
UID
omniauth-auth0の応答はこんな感じです
userinfo: {"provider"=>"auth0", "uid"=>"oauth2|YahooJAPAN|XXXXXXXXXXXXXXXXXXXXXXX", ...すでにomniauth-auth0 を導入できている場合、特にサーバアプリケーション側の変更は不要

