The twitter-oauth
app uses the mrjones/oauth
library to demonstrate:
- How to do the
OAuth
to authenticate your app to use aTwitter
account. - Fetching mentions for that Twitter account.
- Tweeting on behalf of that Twitter account.
The core contents of the app:
twitter-oauth/app/
models
user.go # User struct and in-memory data store
controllers
app.go # All code
The OAuth
process is governed by this configuration:
var TWITTER = oauth.NewConsumer(
"VgRrevelRunFooBarTruingindreamzw",
"l8lOLyIF3peCFEvrEoTc8h4oFwieAFgPM6eegibberish",
oauth.ServiceProvider{
AuthorizeTokenUrl: "https://api.twitter.com/oauth/authorize",
RequestTokenUrl: "https://api.twitter.com/oauth/request_token",
AccessTokenUrl: "https://api.twitter.com/oauth/access_token",
},
)
An overview of the process:
- The app generates a "request token" and sends the user to Twitter.
- The user authorizes the app.
- Twitter redirects the user to the provided redirect url, including an "verifier" in the parameters.
- The app constructs a request to Twitter using the "request token" and the "verifier", to which Twitter returns the "access token".
- The app henceforth uses the access token to operate Twitter on the user's behalf.