1

I created an app in twitter and trying to do basic authentication but I am getting the below error so can anyone help me with this? How to resolve the error?

Callback URL not approved for this client application. Approved callback URLs can be adjusted in your application settings

Akash Sourav Nayak
  • 203
  • 1
  • 8
  • 21

2 Answers2

2

If you do receive this error message, please check the URL that you are using with the callback_url parameter in your oauth/request_token call and make sure that this URL has been whitelisted in your Twitter app settings in the developer portal.

Here is a description on how to solve your issue: https://developer.twitter.com/en/docs/basics/developer-portal/guides/callback-urls.html

Andrea Nagy
  • 1,201
  • 9
  • 21
  • Hi Andrea . Can you tell me how to check whether URL has been whitelisted or not? – Akash Sourav Nayak Sep 28 '18 at 19:28
  • Based on the website: You can make adjustments to your callback URL via the "Apps" page in the developer portal. (Sign up with Twitter.) Developers use callback URLs as part of this integration in order to provide directions on where a user should go after signing in with their Twitter credentials. As part of our continued effort to ensure safety and security on the Twitter developer platform, any developer using Sign in with Twitter must explicitly declare their callback URLs in a whitelist on the "Apps" page in the developer portal. – Andrea Nagy Sep 28 '18 at 19:33
  • I tried to give google.com as callback URL . But its throwing the same error. As you mentioned we have to explicitly declare the callback URLs in a whitelist on the "Apps" page.But i am not able to see any whitelist option or tab there .So can you please guide me how to do that. – Akash Sourav Nayak Sep 28 '18 at 19:37
  • 1
    I am not sure what you are trying to achieve with google as callback url. You have examples here: https://stackoverflow.com/questions/800827/twitter-oauth-callbackurl-localhost-development and here: https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter.html. Also I suppose you can find other tutorials if you search for it. – Andrea Nagy Sep 28 '18 at 19:46
  • Actually i am trying to get the tweets of an specific user .For that i am trying to authenticate the user using Java .But i am not able to find any good resource .DO i have to implement Oauth for that? Can you please help me in this. – Akash Sourav Nayak Sep 28 '18 at 19:50
  • 1
    Yes, you need Oauth for getting user related data. I think this is a good start point for you: https://github.com/wyattisimo/twitter-example-101 And please try to search for answers, there are lots of sources on the internet. – Andrea Nagy Sep 28 '18 at 20:07
  • Thanks for the suggestion. I have gone through many posts but all are outdated. And though i am using springs its bit difficult for me to do. But you haven't told where is the whitelist button is there? – Akash Sourav Nayak Sep 28 '18 at 21:34
  • have you implemented the sign in with Twitter OAuth flow, or not? – Andy Piper Sep 28 '18 at 22:18
  • I am trying t implement but I am getting the error. – Akash Sourav Nayak Sep 29 '18 at 11:58
0

I've been struggling with callback_url and Spring Social for some time.

Add following url to Twitter whitelisted. For localhost use:

https://localhost/auth/twitter

for deployed app:

https://example.com/auth/twitter or https://IP.ADR.ESS/auth/twitter

First make sure it works on localhost, meaning your machine. If it works on localhost but fails afted deploy on specific IP, the problem is most probably with your server IP. Spring Social Twitter creats this urlcallback based on some host parameters. If you deploy on a machine that is behind a proxy, a real callack url may be different than IP addres the app is running on. That was my case. I had two VPS from different vendors. Same config worked on first, failed on second.

jarosik
  • 4,136
  • 10
  • 36
  • 53
  • I am having the same problem as yours. How did you solve it with a real callback url? I meant how do you find out the real callback url behind a proxy? – IdontEvenEven May 02 '22 at 13:28