digits-cordova icon indicating copy to clipboard operation
digits-cordova copied to clipboard

Verification failure

Open Alphatiger opened this issue 9 years ago • 9 comments

App integration is done successfully, Receiving token, but when trying to verify getting 215 bad authentication data. Compared the generated oauth Echo with that of digits web example cannonball, had observed for oauth signature character encoding is missing,

Any suggestions please

Alphatiger avatar Sep 28 '15 16:09 Alphatiger

Hmm not sure how I can help you without seeing what you've done

yangli-io avatar Sep 28 '15 22:09 yangli-io

Hi I got it The problem is with oauth_signature it is having special characters like + and =, and when i am passing them as Headers it is breaking, once i applied the uriencoding it was good.

In order to do this i have applied some crude code, can we improve the plugin to send us back the login response in proper json format so that it will be easy, right now 'X-Verify-Credentials-Authorization' is a long string to extract oauth and apply encoding requires string split etc, if you have any better way of handling please let me know.

Alphatiger avatar Sep 29 '15 14:09 Alphatiger

@Alphatiger , I am facing the same issue. Can you please share code sample to demonstrate, how you fixed it.

nibhatish avatar Oct 07 '15 12:10 nibhatish

facing same issue

nitin7dc avatar Dec 01 '15 09:12 nitin7dc

@nitin7dc Following worked for me. Called digitLoginSuccess function with loginResponse from Digit. function digitLoginSuccess(loginResponse){ // alert(JSON.stringify(loginResponse)); var oAuthHeaders = loginResponse.oauth_echo_headers; var verifyData = { authHeader: oAuthHeaders['X-Verify-Credentials-Authorization'], apiUrl: oAuthHeaders['X-Auth-Service-Provider'] }; console.log(verifyData.apiUrl); console.log(verifyData.authHeader); // all the following code is required to encodeURI signature part of Authorization. We first, have to split , then encode and // then again join the string to make it original var strinput = verifyData.authHeader; var tempStringSignature = 'oauth_signature="'; var tempStringSignatureMethod = '", oauth_signature_method='; var encodedCredentials="";
var tempSplit1 = strinput.split(tempStringSignature); var tempSplit2 = tempSplit1[1].split(tempStringSignatureMethod); var strSignature = encodeURIComponent(tempSplit2[0]); encodedCredentials = tempSplit1[0] + tempStringSignature + strSignature + tempStringSignatureMethod + tempSplit2[1];

      }

nibhatish avatar Dec 01 '15 11:12 nibhatish

@nibhatish this solves the issue, thanks for such an early response!

nitin7dc avatar Dec 01 '15 11:12 nitin7dc

Hello @nibhatish, You have no idea how badly I was looking for a solution to this error Bad Authentication Data. I was integrating digits for web with backend in PHP. I haven't found information about this encoding anywhere, not even in twitter documents. BTW how did you find out about it? That we need to encode oauth_signature before sending request to digits server.

Many Thanks, Waqas

djvickx avatar May 10 '16 15:05 djvickx

@djvickx just a random question, is this digits-cordova package still working for you? It's been a while since I've used this, not sure if twitter has changed how it works.

yangli-io avatar May 11 '16 01:05 yangli-io

@djvickx I also lost some hairs while finding the solution :-). I followed the comment of @Alphatiger about how to fix it and just translated his suggestions in javascript.

nibhatish avatar May 11 '16 06:05 nibhatish