-
Notifications
You must be signed in to change notification settings - Fork 300
Failed to get request token in android and ios. #203
Description
Hello Team
i am facing a issue with this library ( "Failed to get request token" ) Android, IOS both platform.
I also try it with in a fresh project and followed the Twitter app setup process or i got the consumer and secret key's.
But when i requesting with this credentials it is returning the error ("Failed to get request token") some time before it was working in other project but after install the node modules it stopped working.
-
I did some search about this issue and most of developers and referencing to to check your callBack url's on your Twitter
developer app, ( so i remove the previous callbacks and add them again ) but it is still retiring same error. -
After more analysis i found the twitter api's and i try with these api.
1. Get request token api ( Add your consumer key )
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.twitter.com/oauth/request_token?oauth_consumer_key=YOUR_CONSUMER_KEY&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1698819571&oauth_nonce=aPINykwfTb5&oauth_version=1.0&oauth_signature=y7282t0yKdERK%2FgknyH335z1LM4%3D',
headers: {
'Cookie': 'guest_id=v1%3A169875337548246364; guest_id_ads=v1%3A169875337548246364; guest_id_marketing=v1%3A169875337548246364; personalization_id="v1_sqUWzpLK9KbN3iJS3AwtqA=="'
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
2. After run this api it will return a string, we will pass this string in next api.
We need to prepare the url like below.
https://api.twitter.com/oauth/authorize?ADD_YOUR_STRING_FROM_FROM_API_RESPONSE
Then hit this URL in your browser so this will redirect you on app authorization page.
Now i think my Twitter app and its callbacks setup is right.
I checked the Logcat in android studio and here is the my issue.

I saw the code inside the OAuthController file
Inside this startAuth function is calling ( oAuth1aService.requestTempToken)
I think (oAuth1aService.requestTempToken) is throwing Error so inside the newRequestTempTokenCallback function failure function is calling, and it is returning a error message (Failed to get request token)
It is the error response in my node server
{"nativeStackAndroid":[{"lineNumber":94,"file":"OAuthController.java","methodName":"failure","class":"com.twitter.sdk.android.core.identity.OAuthController$1"},{"lineNumber":191,"file":"OAuth1aService.java","methodName":"failure","class":"com.twitter.sdk.android.core.internal.oauth.OAuth1aService$1"},{"lineNumber":48,"file":"Callback.java","methodName":"onFailure","class":"com.twitter.sdk.android.core.Callback"},{"lineNumber":92,"file":"DefaultCallAdapterFactory.java","methodName":"run","class":"retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1$2"},{"lineNumber":942,"file":"Handler.java","methodName":"handleCallback","class":"android.os.Handler"},{"lineNumber":99,"file":"Handler.java","methodName":"dispatchMessage","class":"android.os.Handler"},{"lineNumber":201,"file":"Looper.java","methodName":"loopOnce","class":"android.os.Looper"},{"lineNumber":288,"file":"Looper.java","methodName":"loop","class":"android.os.Looper"},{"lineNumber":7872,"file":"ActivityThread.java","methodName":"main","class":"android.app.ActivityThread"},{"lineNumber":-2,"file":"Method.java","methodName":"invoke","class":"java.lang.reflect.Method"},{"lineNumber":548,"file":"RuntimeInit.java","methodName":"run","class":"com.android.internal.os.RuntimeInit$MethodAndArgsCaller"},{"lineNumber":936,"file":"ZygoteInit.java","methodName":"main","class":"com.android.internal.os.ZygoteInit"}],"userInfo":null,"message":"Failed to get request token","code":"USER_CANCELLED"}
Please help me to fix my issue because it's urgent.
Thank you.