使用以下 Python 代码测试 Oauth2 的 oauth2/userprofile 查询:
verify='/home/claudef/tmp/oauth2/oauth/wso2.pem'
url = "https://extbasicpacman05.podc.sl.edst.red.com:9443/oauth2/userinfo?schema=openid"
headers = { 'Authorization' : "Bearer " + access_token }
r = requests.get(url, headers=headers, verify=verify)
Run Code Online (Sandbox Code Playgroud)
我从 WSO2 身份服务器收到以下错误消息:
error":"insufficient_scope","error_description":"Access token does not have the openid scope"
Run Code Online (Sandbox Code Playgroud)
检查从不记名令牌发射返回的数据,我看到默认值scope=profile,它与userinfo查询中的默认值不匹配,可能使用值scope=openid。
u'token_type': u'bearer', u'scope': u'profile', u'access_token': u'7ae4542fe322d3aba67bf0625039d5f6', u'expires_in': 73, u'refresh_token': u'92d915a25d8bef6ca7ec7b70664c5cbf'}
Run Code Online (Sandbox Code Playgroud)
使用 cURL 命令时也会出现相同的错误。
请给我一些指导,如何解决此问题以从 WSO2 服务器读取用户信息数据。
我已经使用改造与 API 进行通信。当用户登录时,我将帐户保存到数据库,当用户下次访问应用程序时,我从数据库获取数据(所以我跳过了登录屏幕)。问题是当用户的令牌过期时。遇到这种情况该如何处理?
在登录片段中的 伪代码
user = ... //get user from database
if(user != null) {
startActivityAccountActivity();
}
//onButtonClick
emailLogin();
Run Code Online (Sandbox Code Playgroud) 好吧,这可能是一个非常菜鸟或幼稚的问题,但我尝试在互联网上搜索,并且只有在没有找到任何有效的东西后才诉诸堆栈溢出。我一直在阅读有关基于令牌的身份验证以及基于 Cookie 的身份验证。我认为基于令牌的身份验证对于单页 Web 应用程序更好,但无法清楚地理解原因。我将使用 Nodejs 和 AngularJS 来完成同样的任务。
我已经尝试阅读文档并尝试更改默认行为https://flask-jwt-extended.readthedocs.io/en/latest/changing_default_behavior.html来处理错误(该链接显示了如何处理过期的令牌)和在谷歌中搜索我能做的每个关键字组合中的所有内容,但似乎没有人有这方面的例子。
我尝试使用 @jwt.revoked_token_loader 来处理 RevokedTokenError 但它似乎不起作用,因为我像这样应用它
@jwt.revoked_token_loader
def revoked_token_response(revoked_token):
jwtkn = revoked_token['jti']
return jsonsify({
'msg': 'token {} already been revoked!'.format(jwtkn)
)}, 401
Run Code Online (Sandbox Code Playgroud)
实际上,我不知道处理过期令牌的链接上的示例如何具有“expired_token”参数,这种自我声明是否像我上面在“revoked_token”上所做的那样?据我所知,“jti”就像flask-jwt-extended包中的默认值,因为每当我不使用它时我都会看到错误(在我的数据库中,它是不同的,但根本没有问题。
我尝试按照本教程进行操作,在我这边效果很好(以及他的原始代码源),但我发现这个在撤销令牌上也没有捕获异常https://codeburst.io/jwt-authorization-烧瓶内-c63c1acf4eeb
我使用邮递员,如果基于教程链接,这就是我如何得到这个
i do login
i use the access token generated to access protected routes ('/secrets')
i do logout
i use again the access token generated to access protected routes
Run Code Online (Sandbox Code Playgroud)
在最后一个之后,我在服务器端(ide)收到此错误:
....flask_jwt_extended\utils.py", line 216, in verify_token_not_blacklisted
raise RevokedTokenError('Token has been revoked')
flask_jwt_extended.exceptions.RevokedTokenError: Token has been revoked
127.0.0.1 -- [02/Jul/2019 22:25:26] "GET /secrets HTTP/1.1" 500 …Run Code Online (Sandbox Code Playgroud) 我正在尝试让我的 .Net Web API(使用 OWIN 的 Azure API 应用程序)接受用于 client_credentials 授予的 OAuth Bearer 令牌,但我不断收到 401 Unauthorized。
似乎所有 Microsoft 示例都已过时(不符合 Owin 的最新 nuget 包)。
JwtFormat 需要一个 IIssuerSecurityTokenProvider,但它不再存在 - 相反,JwtFormat 需要一个 IIssuerSecurityKeyProvider,但我无法理解如何使用它。
Azure OAuth 服务器正在运行
我已在 Azure Active Directory 中注册了两个应用程序(api 和客户端)。由于这只是快速演示,我将向您提供所有 id 和秘密;)
我可以从 Azure AD 获取令牌,请参阅https://reqbin.com/817shtc2以获取完整的请求,到目前为止一切顺利。
应用程序编程接口
客户端ID:44cf7574-88a2-42d6-9497-bff43cc8dc09
端点:https ://apim-demo-mglentoft.azure-api.net/api/Values (GET)
客户
客户端ID:5f7ee334-b8db-46d3-972f-09f52e186d1d
秘密:ggKp94]HZHWZ.c*5wUC?ToSVfknyqLB3
我按照https://github.com/azureadquickstarts/appmodelv2-nativeclient-dotnet上的示例进行操作,但它引用了 Microsoft.Owin.Security.Jwt.IIssuerSecurityTokenProvider,它在 nuget v4.0.1.0 中不存在。
我尝试仅注释掉 JwtFormat 的第二个参数,但这不起作用。有什么想法如何使用 Microsoft.Owin.Security.Jwt.IIssuerSecurityKeyProvider 来实现此功能吗?
下面是整个startup.cs
我可以使用 .Net Core 来实现此功能,但由于各种原因,我必须坚持使用 .Net Framework 4.7.2
using …Run Code Online (Sandbox Code Playgroud) 我有以下button.json
{
"component": {
"button": {
"padding": { "value": "{size.padding.medium.value}" },
"font-size": { "value": 2 },
"text-align": { "value": "center" },
"primary": {
"background-color": { "value": "hsl(10, 80, 50)" },
"color": { "value": "{color.font.inverse.value}" }
},
"secondary": {
"background-color": { "value": "{color.background.primary.value}" },
"color": { "value": "{color.font.link.value}" }
}
}
}
Run Code Online (Sandbox Code Playgroud)
我可以使用亚马逊样式字典生成样式标记。我想要生成的是 json 中的完整 sass css。
例如:
.component-button {
padding: " ";
font-size: " ";
& .primary {
background-color: "",
color: ""
}
}
Run Code Online (Sandbox Code Playgroud) 我一直在查看Go 令牌文档,并且注意到缺少 bool 的 Go 令牌类型。
是否有不包括在内的原因?
双引号 ( ") 是预处理标记还是未终止的字符串文字?
C11,6.4 词汇元素,语法,1:
preprocessing-token:
header-name
identifier
pp-number
character-constant
string-literal
punctuator
each non-white-space character that cannot be one of the above
Run Code Online (Sandbox Code Playgroud)
C11,6.4.5 字符串文字,语法,1:
string-literal:
encoding-prefix(opt) " s-char-sequence(opt) "
Run Code Online (Sandbox Code Playgroud)
注意:GCC 认为它是未终止的字符串文字:
#if 0
"
#endif
Run Code Online (Sandbox Code Playgroud)
产生:
warning: missing terminating " character
Run Code Online (Sandbox Code Playgroud) 我有一个注册api,它将用户详细信息注册到数据库,它还使用 laravel Passport生成令牌 并将令牌保存到数据库中
现在我正在尝试创建一个get api,它将使用生成的令牌从数据库中获取所有数据
我尝试过什么
在 api.php中
Route::get('/get_user', [userDEtails::class, 'get_user']);
userDEtails.php 控制器
public function get_user(Reqest $req)
{
// what code must i add here
}
Run Code Online (Sandbox Code Playgroud)
在邮递员中,我想在标头中添加令牌作为授权和 api 来工作
我正在使用 Laravel 框架 9.41.0
我有以下正则表达式用于数据验证:
lexer = /(?:
(.{18}|(?:.*)(?=\s\S{2,})|(?:[^\s+]\s){1,})\s*
(.{18}|(?:.*)(?=\s\S{2,})|(?:[^\s+]\s){1,})\s*
(?:\s+([A-Za-z][A-Za-z0-9]{2}(?=\s))|(\s+))\s*
(Z(?:RO[A-DHJ]|EQ[A-C]|HIB|PRO|PRP|RMA)|H(?:IB[2E]|ALB)|F(?:ER[2T]|LUP2|ST4Q))\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\s+\d{10}|\s+)\s*
(\d{6})\s*
(.*)(?=((?:\d{2}\/){2}\d{4}))\s*
((?:\d{2}\/){2}\d{4})\s*
(\S+)
)/x
Run Code Online (Sandbox Code Playgroud)
问题是我必须遍历10000行(平均值)的文件,使用正则表达式执行验证,从而导致解析缓慢的应用程序.
filename = File.new(@file, "r")
filename.each_line.with_index do |line, index|
next if index < INFO_AT + 1
lexer = /(?:
(.{18}|(?:.*)(?=\s\S{2,})|(?:[^\s+]\s){1,})\s*
(.{18}|(?:.*)(?=\s\S{2,})|(?:[^\s+]\s){1,})\s*
(?:\s+([A-Za-z][A-Za-z0-9]{2}(?=\s))|(\s+))\s*
(Z(?:RO[A-DHJ]|EQ[A-C]|HIB|PRO|PRP|RMA)|H(?:IB[2E]|ALB)|F(?:ER[2T]|LUP2|ST4Q))\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\s+\d{10}|\s+)\s*
(\d{6})\s*
(.*)(?=((?:\d{2}\/){2}\d{4}))\s*
((?:\d{2}\/){2}\d{4})\s*
(\S+)
)/x
m = lexer.match(line)
begin
if (m) then …Run Code Online (Sandbox Code Playgroud)