你怎么把一个认证令牌上的URL作为查询参数? [英] How do you put an authentication token on URL as query parameter?

查看:426
本文介绍了你怎么把一个认证令牌上的URL作为查询参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做我的ASP.Net MVC网站PayPal的前preSS结帐。

该网站使用令牌认证,所以我试图把令牌上的贝宝返回URL作为查询参数。

我有拦截到我的网站的所有请求,并从URL或请求头中提取标记的处理程序。

工程罚款从标题得到它,但我得到以下异常时,它的查询参数。我从我的声明主体得到令牌并没有做任何编码/解码。我试过这个方法,但没有运气(发生同样的除外)。

  System.ArgumentException被抓
  的HResult = -2147024809
  消息= Jwt10204:System.IdentityModel.Tokens.JwtSecurityTokenHandler无法读取该字符串:{很长令牌}。
该字符串需要在紧凑JSON格式,它的形式是:'< Base64UrlEn codedHeader>< Base64UrlEnd codedPayload><可选,Base64UrlEn codedSignature方式>'。
  来源= System.IdentityModel.Tokens.Jwt
  堆栈跟踪:
       在System.IdentityModel.Tokens.JwtSecurityTokenHandler.ReadToken(字符串jwtEn codedString)
       在{我们的命名空间} .Providers.JwtTokenServiceProvider.GetToken(字符串值)
       在{我们的命名空间} .TokenAuthorisationController.Post(TokenRequest要求)


原来,问题是,贝宝追加上,然后用逗号URL的结束另一个字符串(看起来像一个PayPal前preSS结帐令牌)作为分隔符,而不是与&象征。

所以我用逗号额外的我JWT令牌之后,除去逗号字符和多余的字符解决了这个问题。

I'm doing a PayPal Express Checkout on my ASP.Net MVC site.

The site uses token authentication so I'm trying to put the token on the PayPal return URL as a query parameter.

I have a handler that intercepts all requests to my site and extracts the token from the URL or the request header.

Works fine getting it from the header but I get the following exception when its a query parameter. I get the token from my claims principal and don't do any encoding/decoding. I've tried this method but had no luck (same exception occurs).

System.ArgumentException was caught
  HResult=-2147024809
  Message=Jwt10204: 'System.IdentityModel.Tokens.JwtSecurityTokenHandler' cannot read this string: '{really long token}'.
The string needs to be in compact JSON format, which is of the form: '<Base64UrlEncodedHeader>.<Base64UrlEndcodedPayload>.<OPTIONAL, Base64UrlEncodedSignature>'.
  Source=System.IdentityModel.Tokens.Jwt
  StackTrace:
       at System.IdentityModel.Tokens.JwtSecurityTokenHandler.ReadToken(String jwtEncodedString)
       at {our namespace}.Providers.JwtTokenServiceProvider.GetToken(String value)
       at {our namespace}.TokenAuthorisationController.Post(TokenRequest request)

解决方案

Turns out the problem was that PayPal appending another string (that look like a PayPal Express Checkout token) on then end of the URL with a comma as a delimiter instead of the "&" symbol.

So I solved the issue by removing the comma character and the extra characters after the comma to extra my JWT token.

这篇关于你怎么把一个认证令牌上的URL作为查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆