How do you put an authentication token on URL as query parameter?

ぐ巨炮叔叔 提交于 2019-12-11 16:34:45

问题


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)

回答1:


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.



来源:https://stackoverflow.com/questions/25437700/how-do-you-put-an-authentication-token-on-url-as-query-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!