【发布时间】:2020-01-31 11:54:33
【问题描述】:
我正在尝试使用 Auth0 作为中介对 GitHub 进行经过身份验证的调用。
我正在关注https://auth0.com/docs/connections/calling-an-external-idp-api 上的指南,但是当涉及到第 2 步时。获取 user_id,我遇到了 /userinfo 端点的问题。
const rp = require('request-promise')
const auth0_options = {
method: 'POST',
url: 'https://MY_DEV_ID/oauth/token',
headers: {'content-type': 'application/x-www-form-urlencoded'},
form: {
grant_type: 'client_credentials',
client_id: 'MY_CLIENT_ID',
client_secret: 'MY_CLIENT_SECRET',
audience: 'https://MY_DEV_ID/api/v2/'
}
};
const auth0_result = JSON.parse(await rp(auth0_options));
const access_token_one = auth0_result.access_token;
然后我尝试按照https://auth0.com/docs/api/authentication#user-profile 中的描述调用 userinfo 端点
const userinfo_options = { method: 'GET',
url: 'https://MY_DEV_ID/userinfo',
headers: { 'Authorization' : `Bearer ${access_token_one}`}
};
const userinfo_result = JSON.parse(await rp(userinfo_options));
但是这个不起作用,它返回一个空对象,我认为这是由于它未经授权。
我在 SO 上查找了许多关于 /userinfo 的先前问题,但发现在所有情况下,我发现问题是我已经确定的问题(令牌、受众等)
编辑: 我正在尝试使用的 auth0 api 的 openid 配置:
scopes_supported": [
"openid",
"profile",
"offline_access",
"name",
"given_name",
"family_name",
"nickname",
"email",
"email_verified",
"picture",
"created_at",
"identities",
"phone",
"address"
],
"response_types_supported": [
"code",
"token",
"id_token",
"code token",
"code id_token",
"token id_token",
"code token id_token"
],
【问题讨论】:
标签: node.js access-token auth0 alexa-skills-kit