- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 Oauth 2.0 访问 Bexio API。我正在尝试在 Node.js 服务器上实现此功能。第一步(获取访问代码)正在运行,并且我的回调方法已执行。然而,获取访问 token 总是失败。当我执行发布请求来获取访问 token 时,我总是收到“invalid_client”错误,其描述为“在 header 或正文中找不到客户端凭据”。
我有一个客户端 ID 和密码,并且我设法使用 postman 获取了访问 token ,所以显然错误出在我的代码中。有人建议我需要对请求正文进行编码(客户端 key 中可能有“=”之类的内容),但我找不到太多相关信息。
这是我的代码:
let redirect_uri =
process.env.REDIRECT_URI ||
'http://localhost:8888/callback'
app.get('/login', function(req, res) {
res.redirect('https://office.bexio.com/oauth/authorize?' +
querystring.stringify({
response_type: 'code',
client_id: CLIENT_ID,
scope: 'contact_edit monitoring_show',
state: 'abc',
redirect_uri
}))
})
app.get('/callback', async (req, res) => {
const code = req.query.code
axios.post('https://office.bexio.com/oauth/access_token', {
grant_type: 'authorization_code',
code: code,
redirect_uri: redirect_uri,
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET
})
.then(response => {
console.log(response)
})
.catch(error =>{
console.log(error)
})
});
这是http请求:
{ url: 'https://office.bexio.com/oauth/access_token',
method: 'post',
data:
'{"grant_type":"authorization_code",
"code":CODE,
"redirect_uri":"http://localhost:8888/callback",
"client_id":CLIENT_ID,
"client_secret":CLIENT_SECRET}',
headers:
{ Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json;charset=utf-8',
'User-Agent': 'axios/0.19.0',
'Content-Length': 265 }
我需要一个访问 token ,但我总是收到“invalid_client”错误,其描述为“在 header 或正文中找不到客户端凭据”
最佳答案
您必须以 application/x-www-form-urlencoded
格式将数据发送到 OAuth2 token 端点。 Axios 默认为 application/json
。您可以在此处查看使用该格式的文档:https://github.com/axios/axios#using-applicationx-www-form-urlencoded-format 。在你的情况下,它会像这样完成:
const params = new URLSearchParams();
params.append('grant_type', 'authorization_code');
params.append('code', code);
params.append('redirect_uri', redirect_uri);
params.append('client_id', CLIENT_ID);
params.append('client_secret', CLIENT_SECRET);
axios.post('https://office.bexio.com/oauth/access_token', params)
关于node.js - 如何修复 Node.js 中 Oauth 2.0 的 'invalid_client' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57877287/
我试图实现的目标: iOS 客户端向后端发送 JWT token 。 后端 (Java) 调用 https://appleid.apple.com/auth/token验证 token 。 到目前为止
我正在开发一个受 OAuth2 身份验证保护的基本 grails 应用程序——code here .它只不过是 spring-security 和 spring-security-oauth 插件对于
我已经设置了一个在 IIS 中运行的 IdentityServer3 实例。 var validators = new List> { new
我正在尝试验证 Connect2id使用 Go test 进行设置,我收到以下错误。 "Client authentication failed: Missing client authenticat
我面临一个非常糟糕的问题,因为我阅读了很多指南和教程,但没有任何效果。 结果总是一样的:{"error":"invalid_client"} 我得到了代码、identityToken 和我需要的一切—
美好的一天, 我在获取访问 token 时遇到问题。我已按照此处的指南进行操作:http://developers.box.com/oauth/并且已经获取了我的 client_id、client_s
我正在尝试使用 IdentityServer3,但不知道为什么我总是收到“invalid_client”错误,无论我做什么。 这是我正在使用的代码: //Startup.cs (Auth c# pro
http://localhost:3000/oauth/token { "error": "invalid_client", "error_description": "Client authenti
store_token = context.acquire_token_with_device_code(resource_uri, code, client_id) File "/Users/j
我已在我的网络服务器上安装了 Google Drive Realtime API 示例文件,如下 these instructions ,包括在 Cloud Console 中生成 client_id
我正在为我的应用程序使用 Google Apps API,并尝试使用 OAuth2 对其进行授权。我使用 Google API 控制台创建了一个项目和其中的一个应用程序。我使用以下 URL 进行授权:
我正在使用带有 django-oauth-toolkit 的 django rest 框架。当我在本地主机上请求访问 token 时,它会给我访问 token ,如下所示 ~/django_app$
我有一个使用 ASP.NET Identity 运行的 IdentityServer4 应用程序。我想使用它,以便其他应用程序的用户可以通过我的远程身份服务器登录。 我已使用以下设置在身份服务器中配置
我正在使用带有 django-oauth-toolkit 的 django rest 框架。当我在本地主机上请求访问 token 时,它会给我访问 token ,如下所示 ~/django_app$
我在使用 Amazon Cognito 中的授权代码流时遇到困难。我正在尝试构建的工作流程如下: 用户使用内置 Cognito UI 进行身份验证。 Cognito 使用授权码重定向回来。 我将代码发
我有一个旧项目,试图从谷歌分析中检索数据。 它不工作,所以我想找出问题所在。 找到了在服务器端使用 Analytics 的示例代码。 scope = ['https://www.googleapi
我们正在使用 ShareKit对于在 youtube 上分享视频,代码工作正常但现在出现错误 YouTube authentication finished with error:Error Dom
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 3 年前。 Improve this qu
我正在使用 python 社交身份验证在我的应用程序上实现谷歌登录。但是我得到以下错误 Error: invalid_client The OAuth client was not found. 我已
我正在尝试使用 spotifyr 包从 Spotify 中提取数据,但是任何需要访问 token 的函数都不起作用(例如 get_my_recently_played(limit = 5))。运行时出
我是一名优秀的程序员,十分优秀!