How can I get Yahoo OAuth to work when I develop locally when my local domain is not registered with Yahoo?

Viewed 13337

I'm working on an app that uses Yahoo OAuth. The OAuth had been working fine but I just registered my domain with Yahoo and now it will not let me use the OAuth when I develop locally because "Custom port is not allowed or the host is not registered with this consumer key."

The issue is because my call back URL is to a domain that is not registered with Yahoo (http://localhost:8080/welcome).

I'm not sure what to do. I'm also new to development so if you could be specific with suggestions that would be awesome! Any help is greatly appreciated.

6 Answers

Hiii... yahoo works on localhost :).. what you have to do is while registering for a yahoo consumer key and secret key, the registration page asks you what type of application is yours. I guess it gives you two options , website and the oder one as stand alone app. Choose stand alone app as in your case. Then it will give you a pair of keys, and it will work on localhost :). Enjoy!

After many attempts, I too came to the conclusion that Yahoo's redirect_uri does not seem to work with ports other than 80.

The one solution that worked for me:

  1. Download ngrok
  2. Run the app and input ngrok http xxxx in the console - where xxxx is the port you are trying to access
  3. The command will generate a http://xxxxxx.ngrok.io forwarding link that can be used for Yahoo's needs
  4. Create a new Installed Application at https://developer.yahoo.com/apps/create/ and input http://xxxxxx.ngrok.io in the Callback Domain field.
  5. Links should now work with this redirect_uri

As of writing, setting the Application Type to Installed Application and then leaving the Callback Domain blank will give you errors.

What works is configuring 127.0.0.1 as the Callback Domain for the app. This works regardless if you are choosing Web Application or Installed Application as the Application Type. However, Yahoo! does not accept callback URLs with ports in it so you have to make sure your app listens to port 80 (or 443 if https) when running locally.

Another less ideal option would be using some random non-existent domain like local.dev.env.com as Callback Domain and then editing your hosts file by adding this:

127.0.0.1 local.dev.env.com

This will forward all requests on local.dev.env.com to 127.0.0.1.

Related