-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SignatureCalculator.constructAuthHeader()] Should nonce be URL encoded? #57
Comments
Hi Boris, Thanks for the issue report. I did some investigation into our use of Base64 currently in the library. The alphabet used in java.util.Base64 for url-safe seems to be
and so I don't think we see this particular problem when using this library. If you catch your exceptions, could you call
on them to print to a log, and add to this issue report? This will include more detailed error information, to help with investigation into this issue. Thanks, |
Hi Ken, Apologies for the delay as this slipped through. I believe your analysis makes sense and this only comes from Base 64 switch. I will work on reproducing the issue and share the exception content. Thanks, Boris |
Here is the log:
This said, I think this issue can be closed as it doesn't happen in this official library, only in my tweaked code. |
Thank you for the details. I have filed a ticket internally for the server team to look into. If this is all that's blocking usage of the library from Android, I think this might be worth fixing anyway. From what I can tell the OAuth 1.0 spec RFC 5849 is ambiguous about characters used for oauth_nonce, so if we fall back to RFC 2616, '%' should be supported. |
Hi @boriguen , I think from reading the OAuth specs https://tools.ietf.org/html/rfc5849#section-3.5.1 , it says "1. Parameter names and values are encoded per Parameter Encoding (Section 3.6)." So if your nonce includes '+' and/or '/', the client must use it plaintext in the signature calculation, but must URL-encode it when sending it in the Authorization header. Have you tried replacing '+' and '/' in your nonce values, with '-' and '_', respectively, in your replacement for
? That would effectively provide you with a URL-safe Base64-encoder. Note knowing how you overrode the lack of java.util.Base64 class in your environment, I'm not sure how you handled that. If you could provide more details on your work-around, that might help. |
Hi,
I have observed a pattern regarding success or failure of the authorization request depending on whether the nonce was URL encoded while containing special characters. Removing the urlEncode() call seems to make all requests succeed.
Here are a couple examples to illustrate:
Successes
Failures
I haven't investigated too deep into the issue but removing the urlEncode(nonce) and only appending nonce as-is seems to lead a 100% success rate, even with oauth_nonce="7g+/D1" or oauth_nonce="Zs/a9h".
Please feel free to check the hypothesis a bit further.
Thanks,
Boris
The text was updated successfully, but these errors were encountered: