You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OAauth1 is a Go client implementation of the OAuth1 spec. It supports authorizing HTTP requests.
4
+
OAauth1 is a Go implementation of the [OAuth 1 spec](https://tools.ietf.org/html/rfc5849).
5
5
6
-
The OAuth1 package takes design cues from the [golang.org/x/oauth2](https://godoc.org/golang.org/x/oauth2), providing an http.Client which handles signing requests and authorization via a custom Transport.
7
-
8
-
If an official oauth1 package were to be developed by the Go authors, I'd recommend you use that implementation instead. However, at this time, no official implementation exists.
9
-
10
-
## Note
11
-
12
-
This library is currently under development. It provides a signing http.Client, but does not yet completely implement the spec or handle credential retrieval from a provider backend.
6
+
It takes design cues from [golang.org/x/oauth2](https://godoc.org/golang.org/x/oauth2), providing an `http.Client` which handles authorization and signing.
13
7
14
8
## Install
15
9
@@ -19,11 +13,39 @@ This library is currently under development. It provides a signing http.Client,
An `Endpoint` groups an OAuth provider's URLs for getting a request token, allowing users to authorize applications, and getting access tokens. Endpoints for common providers like [twitter](twitter) and [dropbox](dropbox) are provided in subpackages.
19
+
20
+
A `Config` stores a consumer application's consumer key and secret, the callback URL, and the Endpoint to which the consumer is registered. It provides OAuth 1 authorization flow methods and a `Client(token *Token)` method which returns an `http.Client` which will transparently authorize requests.
21
+
22
+
An OAuth1 `Token` is an access token which allows requests to be made as a particular user. It has fields `Token` and `TokenSecret`. If you already have an access token, skip to [Authorized Requests](#Authorized Requests).
23
+
24
+
If you've used [golang.org/x/oauth2](https://godoc.org/golang.org/x/oauth2) before, this organization is similar.
23
25
24
-
Create an application `Config` with a `ConsumerKey` and `ConsumerSecret`. Obtain a token credential in some way (many providers offer a web interface or command line tool for this) and create a `Token`.
26
+
### Authorization Flow
27
+
28
+
The OAuth 1 authorization flow to request that a user grant an application access to his/her account (via an access token) typically looks like:
29
+
30
+
* User visits Consumer's "/login" route (via "Login with Provider" button)
31
+
* Login handler calls `config.GetRequestToken()`
32
+
* Login handler redirects user to `config.AuthorizationURL(rt *RequestToken)`
33
+
* Provider calls Consumer's CallbackURL with a `verifier`
Copy file name to clipboardExpand all lines: examples/README.md
+20-15Lines changed: 20 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,21 +3,26 @@
3
3
4
4
## Twitter
5
5
6
-
### Login Flow (PIN)
7
-
8
-
A consumer application can obtain a Twitter Access Token for a user by requesting the user grant access via [3-legged](https://dev.twitter.com/oauth/3-legged) or [PIN-based](https://dev.twitter.com/oauth/pin-based) OAuth 1.
Consumer was granted an access token to act on behalf of a user.
19
-
token: ddddd-xxxxx
20
-
secret: yyyyyy
6
+
### Login Flow (PIN-based)
7
+
8
+
An application can obtain a Twitter Access Token for a user by requesting the user grant access via [3-legged](https://dev.twitter.com/oauth/3-legged) or [PIN-based](https://dev.twitter.com/oauth/pin-based) OAuth 1.
9
+
10
+
```
11
+
export TWITTER_CONSUMER_KEY=xxx
12
+
export TWITTER_CONSUMER_SECRET=yyy
13
+
```
14
+
15
+
Run `twitter-login.go` to authorize the consumer application to a Twitter account.
Consumer was granted an access token to act on behalf of a user.
23
+
token: ddddd-xxxxx
24
+
secret: yyyyyy
25
+
```
21
26
22
27
Note that website backends should define a CallbackURL which can receive a verifier string and request an access token, "oob" is for PIN-based agents such as the command line.
0 commit comments