Localhost callback url for OAuth1 is "invalid website url"


#1

On the Twitter developer interface this is what I get when I try to use a localhost url for callback.

This was ok on the previous interface (the one that is shown as soon deprecated: apps.twitter.com)

How do you manage to test Twitter OAuth locally with this?


#2

There are few ways around it:

  1. Use IP address
  2. Create a fake domain for testing and resolve it locally on your machine
  3. Register your own testing domain
  4. Have subdomain for testing: e.g local.yourrealdomain.com (I personally use this, works well for ssl too)
  5. Use the legacy interface for now, and hope that twitter will fix the new interface before depreciation :slight_smile:

#3

Thank you @Connexinet!

But this looks like a recurring problem, how is this not handled properly by Twitter while so many developers are complaining? What you suggested works, but here are my concerns:

  • 127.0.0.1 instead of localhost works but I work with localhost, not 127.0.0.1 and I don’t want to adapt my code for Twitter only
  • Creating fake hosts works too but if I work on many projects on many computers this is a pain
  • Using a real domain will help only if I already have a domain available
  • The legacy interface has been disabled last month, I was using it until now

#4

I don’t know why they haven’t fixed it, may be because we have been using workarounds :slight_smile:

  1. Not sure why you would need to adapt your code, ideally one shouldn’t hardcode the IP or domain in the code, but if you have good reasons you can use the other workarounds
  2. Yeah I hear you
  3. True, but it only costs $10 to get a domain, not huge deal tbh
  4. Only disabled to create new apps, so you can create the app in the new interface and edit in the old one (yeah, it’s a bit of a pain, but hopefully they fix it before full deprecation)

#5
  1. Actually I sometimes need to set some urls in my config files, as locally I could have multiple Docker containers for multiple purposes, some addresses (or at least ports) may need to be set

  2. That may be an idea!! Thanks for the advice :slight_smile:

  3. Omg you are right! That’s great :joy:

Thanks again @Connexinet!


#6

my pleasure!


#7

One note on point #4 in @Connexinet’s latest response - You can edit apps in the new interface if you have applied for a new account. You can also do so on apps.twitter.com

You can read more about that here.


#8

Hi @LeBraat,
Yes, but the problem is that editing in the new interface when you have a dev account is kinda broken (doesn’t allow localhost).
Would be great if you guys can fix it.

Thanks,