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

家住魔仙堡 提交于 2019-12-04 01:11:54

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!

I just hit this issue today and I found the simplest solution was just to register for a separate key for my development environment. As long as you don't verify the domain for that key, you shouldn't hit any issues.

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
Malcolm White

Addressing Muhammad's comment in Vignes's answer here because I can't comment. You should be able to use a callback with a stand alone app if you specify 127.0.0.1 as the callback domain. You may also needed to change the port that your local server is listening to, because you cannot request that yahoo use e.g. port 8000. Make sure your local server is listening to port 80.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!