最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Auth0 userinfo请求无法处理

运维笔记admin9浏览0评论

Auth0 userinfo请求无法处理

Auth0 userinfo请求无法处理

我正在尝试使用Auth0作为中介对GitHub进行身份验证的调用。

我正在遵循,但涉及到step2。在获取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;

然后我尝试按

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"
  ],

[我正在尝试使用Auth0作为中介对GitHub进行身份验证的调用。我正在遵循,但是涉及到step2。 ...

回答如下:

[很显然,您从我的access token中获得的auth0_result不是userinfo的当前值,以至于需要一个不同的令牌。我正在以alexa技能运行此代码,我的初始access token来自设置过程中的帐户关联。

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论