Code Monkey home page Code Monkey logo

Comments (2)

mrjones avatar mrjones commented on June 16, 2024

Hello, and thanks for the bugreport! Sorry for not getting to it sooner.

The basic issue is:

  1. GetRequestTokenAndUrl returns a RequestToken and a URL
  2. The user is sent to that URL (and is subsequently redirected back to us along with a verification code).
  3. When calling AuthorizeToken: the RequestToken must be the same token from step 1. (There's an association between the request token, and some parameters in the URL we redirect the user to.)

So, it's not going to work to call GetRequestTokenAndUrl a second time to get a new RequestToken. Instead we must save the token from the first call.

I modified your code and wrote up a quick example of doing so here:
https://github.com/mrjones/oauth/blob/master/examples/twitterserver/twitterserver.go
It's not very elegant (it just uses a global variable), but I just wanted something that worked to demonstrate the technique.

Please let me know if this helps you get your code working! If you're happy, we can close out this bug.

One other unrelated/side note:
When redirecting the user: you probably want to consider "http.StatusTemporaryRedirect" instead of "http.StatusMovedPermanently". They both cause the user to be redirected. However, the second status will (usually) cause the browser to skip over your server, and redirect straight to twitter (this is bad because GetRequestTokenAndUrl won't be called!). The temporary redirect status will ensure the browser always checks your server first, before being redirected.

from oauth.

shalakhin avatar shalakhin commented on June 16, 2024

It helped! Thank you! It works now. Issue can be closed :)

from oauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.