How to encode the access token properly
-
Sunday, December 04, 2011 11:52 AM
http://api.microsofttranslator.com/v2/Ajax.svc/Translate?appId=Bearer%20http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=0166541233&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&Audience=http%3a%2f%2fapi.microsofttranslator.com&ExpiresOn=1322323459&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=0qIUvO513ttc4iBzJN%2b9An3GmUbnggQwT8R5Y3pVSWs%3d&text=search&from=en&to=ja
Is this access token encoded properly? if not what characters need to be encoded? "&" ? "="?
This gives me
ArgumentException: The Web Token must have a signature at the end. The incoming token did not have a signature at the end of the token. : ID=3835.V2_Json.Translate.3A018452"
All Replies
-
Thursday, June 14, 2012 9:58 AM
The appId in your query string
Bearer%20http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=0166541233&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&Audience=http%3a%2f%2fapi.microsofttranslator.com&ExpiresOn=1322323459&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=0qIUvO513ttc4iBzJN%2b9An3GmUbnggQwT8R5Y3pVSWs%3d
is wrong.
For the appId, you must first obtain the auth token through the POST request, prepend it with the "Bearer " and then you must encode the full string.
This encoded string is the appId that is to be used here. Not this string.
For your reference, if you have properly encoded the token, the token will start something like "Bearer+...." and not "Bearer%20". I used Python's urllib.urlencode for encoding the auth "Bearer " and token to the authId string.
I know that this thread is older for 6 months. I fell into the same problem at first. I couldn't find solution through google or bing. Solution came by trial and error. So I thought this information might save some one's time.
- Proposed As Answer by spazinvader Thursday, June 14, 2012 9:58 AM
- Marked As Answer by Laurence MoroneyMicrosoft Employee, Moderator Thursday, June 14, 2012 5:39 PM

