gpt4 book ai didi

javascript - 使用 hello.js 的自定义 OAuth2 提供程序

转载 作者:行者123 更新时间:2023-11-29 21:51:32 24 4
gpt4 key购买 nike

我正在开发符合 RFC6749 的自定义 OAuth2 授权服务器(旧初始版本 @ https://github.com/gvaduha/OAuth2CppLib),并希望将 hello.js 用于单页客户端。开始时我做了什么:

  1. 创建了 src/modules/myoauth.js
(function(hello){
hello.init({
myoauth : {
name : 'myoauth',

oauth : {
version : 2,
auth : 'https://localhost/oauth2/authorize',
grant : 'https://localhost/oauth2/token'
},
refresh : false,
scope : {
basic : 'profile'
},
scope_delim : ' ',
base : 'https://localhost/',
get : {
"me" : "profile"
},
}
});
})(hello);
  1. 将提供程序添加到 demos/client_ids.js
var CLIENT_IDS = {
myoauth : 'OAuthTestClientId',
windows : WINDOWS_CLIENT_ID,
google : GOOGLE_CLIENT_ID,
facebook : FACEBOOK_CLIENT_ID
};
  1. 向 demos/login-events.html 添加了以下几行
<button onclick="login('myoauth')">Login myoauth</button>
<script src="../src/modules/myoauth.js"></script>

但这一切都是徒劳的。当我在服务器身份验证后单击登录页面然后授权然后页面回复 302 重定向到

http://localhost/xxx/redirect.html#token_type=Bearer&access_token=XkGxfTVZWgdFuXTuc64du8DK375JurgOT2CDqv0QGd&expires_in=3600&

当我关闭弹出页面时说

callback:{
"error": {
"code": "cancelled",
"message": "Login has been cancelled"
},
"network": "myoauth"
}auth:{
"error": {
"code": "cancelled",
"message": "Login has been cancelled"
},
"network": "myoauth"
}auth.failed:{
"error": {
"code": "cancelled",
"message": "Login has been cancelled"
},
"network": "myoauth"
}

我做错了什么?顺便说一句:当我更改它的 ID 以指向我注册的应用程序客户端时,Google 工作正常。

最佳答案

在您给出的示例中,OAuth2 响应似乎没有维护“状态”URI 参数。

关于javascript - 使用 hello.js 的自定义 OAuth2 提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28898880/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com