How do I develop against OAuth locally?

后端 未结 7 814
孤独总比滥情好
孤独总比滥情好 2020-12-08 02:38

I\'m building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously

相关标签:
7条回答
  • 2020-12-08 03:14

    This was with the Facebook OAuth - I actually was able to specify 'http://127.0.0.1:8080' as the Site URL and the callback URL. It took several minutes for the changes to the Facebook app to propagate, but then it worked.

    0 讨论(0)
  • 2020-12-08 03:14

    localtunnel [port] and voila

    http://blogrium.wordpress.com/2010/05/11/making-a-local-web-server-public-with-localtunnel/

    http://github.com/progrium/localtunnel

    0 讨论(0)
  • 2020-12-08 03:16

    This may help you:

    http://www.marcworrell.com/article-2990-en.html

    It's php so should be pretty straightforward to set up on your dev server.

    I've tried this one once:

    http://term.ie/oauth/example/

    It's pretty simple. You have a link to download the code at the bottom.

    0 讨论(0)
  • 2020-12-08 03:28

    In case you are using *nix style system, create a alias like 127.0.0.1 mywebsite.dev in /etc/hosts (you need have the line which is similar to above mentioned in the file, Use http://website.dev/callbackurl/for/app in call back URL and during local testing.

    0 讨论(0)
  • 2020-12-08 03:28

    You could create 2 applications? 1 for deployment and the other for testing.

    Alternatively, you can also include an oauth_callback parameter when you requesting for a request token. Some providers will redirect to the url specified by oauth_callback (eg. Twitter, Google) but some will ignore this callback url and redirect to the one specified during configuration (eg. Yahoo)

    0 讨论(0)
  • 2020-12-08 03:29

    Two things:

    1. The OAuth Service Provider in question is violating the OAuth spec if it's giving you an error if you don't specify a callback URL. callback_url is spec'd to be an OPTIONAL parameter.

    2. But, pedantry aside, you probably want to get a callback when the user's done just so you know you can redeem the Request Token for an Access Token. Yahoo's FireEagle developer docs have lots of great information on how to do this.

    Even in the second case, the callback URL doesn't actually have to be visible from the Internet at all. The OAuth Service Provider will redirect the browser that the user uses to provide his username/password to the callback URL.

    The two common ways to do this are:

    1. Create a dumb web service from within your application that listens on some port (say, http://localhost:1234/) for the completion callback, or
    2. Register a protocol handler (you'll have to check with the documentation for your OS specifically on how to do such a thing, but it enables things like <a href="skype:555-1212"> to work).

    (An example of the flow that I believe you're describing lives here.)

    0 讨论(0)
提交回复
热议问题