digits-cordova
digits-cordova copied to clipboard
Verification failure
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
Hmm not sure how I can help you without seeing what you've done
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 , I am facing the same issue. Can you please share code sample to demonstrate, how you fixed it.
facing same issue
@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 this solves the issue, thanks for such an early response!
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 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.
@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.