Commit Graph

89 Commits

Author SHA1 Message Date
Burcu Dogan ce5ea7da93 oauth2: rename SetParam to SetAuthURLParam
SetParam is quite vague to represent an Option that sets the auth
URL query parameters. Renaming it for explicitness.

Fixes #108.

Change-Id: Ic9f0181097820ee83404c9432451d71658dd8c67
Reviewed-on: https://go-review.googlesource.com/8491
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-06 14:29:48 +00:00
Russell Haering 3046bc76d6 oauth2: allow callers to pass arbitrary auth URL parameters
Many OAuth 2.0 implementations support parameters beyond those supported
by this library. This change exports a SetParam function for
constructing arbitrary key/value parameters.

Change-Id: Ice4179e7c5341bbeac8a53e389b32d59415740fa
Reviewed-on: https://go-review.googlesource.com/8054
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-31 07:24:46 +00:00
Kun 40163b0293 oauth2: Add Strava to list of broken oauth2 endpoints
Fixes #101

Change-Id: I26b460dd0261c9599b2917ff97fa4f0c13218a3e
Reviewed-on: https://go-review.googlesource.com/7850
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-19 23:02:46 +00:00
Andrew Gerrand c4932a9b59 oauth2: clarify docs on Exchange (nil context isn't ok)
Fixes golang/oauth2#100

Change-Id: I28afb4f02b817ffd0ff91fb10bfca5306d2c21c6
Reviewed-on: https://go-review.googlesource.com/7615
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-03-16 02:10:04 +00:00
Kun 42633ef623 oauth2: Add TrainingPeaks to list of broken oauth2 endpoints
Fixes #97

Change-Id: I8c61214aeb5fdd049a4eddbf8e8a25b130c908b0
Reviewed-on: https://go-review.googlesource.com/7450
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-12 02:54:27 +00:00
Alex Bramley 7e88c64e80 oauth2: Add Pushbullet to set of broken providers.
https://api.pushbullet.com/ accepts client_secret as a POST body parameter
but not via HTTP basic auth, so it needs to be on this list. I have asked
them to fix it properly too :-)

Change-Id: Iff3cba20592c66d5a38755f47b05f1e992dfbad6
Reviewed-on: https://go-review.googlesource.com/7381
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-12 01:13:50 +00:00
Nikolay Turpitko 2167774341 oauth2: long if condition in providerAuthHeaderWorks replaced with loop
Long if condition replaced with loop.

Related to issue #41.

Change-Id: Ib5b88ce2ee2841e9b6c24d78f93bb027141bf678
Reviewed-on: https://go-review.googlesource.com/7290
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-03-11 04:57:51 +00:00
Nikolay Turpitko 6d4eed4495 oauth2: fix expires_in for PayPal
PayPal returns "expires_in" token field as string, not integer.
So, current implementation cannot unmarshal json of tokenJSON due type mismatch.
This patch fixes the issue declaring field as interface{} in tokenJSON and performing type switch in "func (e *tokenJSON) expiry()".

Related to issue #41.

Change-Id: I69301e08c8a56fca049ca47906e32528cd22aef9
Reviewed-on: https://go-review.googlesource.com/6924
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-10 04:54:57 +00:00
Nikolay Turpitko 10e6bf9f9d oauth2: provider list modified in providerAuthHeaderWorks
Added vk.com and odnoklassniki.ru to provider list in providerAuthHeaderWorks.

Related to issue #41.

Change-Id: If1374528e8f1200d22f8694c5e32cdeae6ebb6ea
Reviewed-on: https://go-review.googlesource.com/6925
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-08 22:43:19 +00:00
HuKeping 5a0a1b2881 oauth2: remove unnecessary ClientSecret check
Since the empty client secret is permitted by the OAuth 2.0 spec.
The check for clientSecret in retriveTokoen is unnecessary.

Redo #6740

Signed-off-by: Hu Keping <hukeping@huawei.com>

Change-Id: I9126c79a1f8b9d6051c213ee3f93c442a36ca65d
Reviewed-on: https://go-review.googlesource.com/6900
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-05 23:19:29 +00:00
Andrew Gerrand 96e89befdc oauth2: remove oauth2.Context type, simplify App Engine token code
You can now use the "google.golang.org/appengine" packages on both
Managed VMs and App Engine Classic(TM). The newer packages use the
context.Context instead of appengine.Context, so we no longer need the
oauth2.Context type.

Some clients will require code changes, replacing oauth2.Context or
appengine.Context with context.Context (imported from
the repository "golang.org/x/net/context").

Users of classic App Engine must switch to using the new
"google.golang.org/appengine" packages in order to use the oauth2
package.

Fixes #89

Change-Id: Ibaff3117117f9f7c5d1b3048a6e4086f62c18c3b
Reviewed-on: https://go-review.googlesource.com/6075
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-03-05 03:18:37 +00:00
Ryan Lower 85a72d36ea oauth2: Add stripe connect to list of bad OAuth2 providers
Stripe connect only accepts client secret using via the
Authorization header using 'Bearer' as the method (not 'Basic').

Change-Id: I978d9ce2092fbad3c1a00fde21d689c8e57a3cf1
Reviewed-on: https://go-review.googlesource.com/5532
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-23 02:33:40 +00:00
James Sweet 35468a7526 Adds twitch.tv to the list of known OAuth2 providers that do not implement the spec fully.
Change-Id: I4db53ae2d039de3ddf9cb84e4211d2e0c4f6c41f
Reviewed-on: https://go-review.googlesource.com/5180
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-18 19:43:35 +00:00
Péter Surányi b0e7ac8c3a oauth2: Context godoc typo fix
Change-Id: I9fbc394a6545754621e808f5d6c4f7622248eaa2
Reviewed-on: https://go-review.googlesource.com/4163
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-08 18:20:03 +00:00
Andrew Gerrand 1406aeefb0 oauth2: clarify comment about tokenRefresher's thread safety
Change-Id: I9a3faedb8faf7701be7c82c7fff964b56d7c96c8
Reviewed-on: https://go-review.googlesource.com/4116
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-07 21:36:27 +00:00
Jim Cote cc2494a288 oauth2: fixes tokenRefresher.Token() ignores new refresh_token
Fixes bug documented in Issue #84 (https://github.com/golang/oauth2/issues/84#issuecomment-72711375).

During a refresh request, a new refresh token MAY be returned by the authorization server.  When this occurs, tokenRefesher.Token() fails to capture the new refresh token leaving it with an invalid refresh token for future calls.

Change-Id: I33b18fdbb750549174865f75eddf85b9725cf281
Reviewed-on: https://go-review.googlesource.com/4151
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-07 21:11:15 +00:00
Paul Rosania 6f28996586 oauth2: Resource Owner Password Credentials grant
Adds support for the Resource Owner Password Credentials grant type, which
allows trusted clients to exchange user credentials for an access token
directly. This is generally a bad idea, but is extremely useful in some
situations, where an external redirect is undesirable or impossible.

See https://tools.ietf.org/html/rfc6749#section-4.3

Change-Id: I28efd77957bcf8e1174e93ba0c64a990b94eb839
Reviewed-on: https://go-review.googlesource.com/3862
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-02-06 10:06:27 +00:00
Aaron Jacobs 7b840c3264 oauth2: Remove what appears to be an out of date comment.
TokenRefresher with that capitalization is not a symbol, and SetToken
doesn't occur anywhere in the package as far as I can tell.

Change-Id: If61f059ed8bb1ca21e27aa99669e542160747fe7
Reviewed-on: https://go-review.googlesource.com/3958
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-05 23:49:51 +00:00
Aaron Jacobs 53c5ae1b31 oauth2: Fix some redundant wording in the docs for AccessTypeOnline.
Change-Id: I124553bd38b229e409e152cf364d55c847b70ba4
Reviewed-on: https://go-review.googlesource.com/3950
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-05 16:18:09 +00:00
Andrew Gerrand 27daa780a8 oauth2: add googleapis.com to list of broken oauth2 endpoints
Fixes #85

Change-Id: Ic60eee227763ab4041248716880416056c850f95
Reviewed-on: https://go-review.googlesource.com/3873
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-02-04 14:04:51 +00:00
Brad Fitzpatrick ed997606a9 oauth2, oauth2/jwt: break JWT off into its own package
Change-Id: Iaaa36728f87744e0d9609674f0d0ad96e6ac80b4
Reviewed-on: https://go-review.googlesource.com/2198
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-01-02 18:35:08 +00:00
Brad Fitzpatrick dfb470cc49 oauth2: fix typo in Token docs and clarify mutability of Token
Change-Id: I1093cffbd4b6fe25cd5b7cfb31e820b15fcfa41f
Reviewed-on: https://go-review.googlesource.com/2197
Reviewed-by: Burcu Dogan <jbd@google.com>
2014-12-31 03:26:08 +00:00
Brad Fitzpatrick a379e41d44 oauth2, oauth2/google: add, use ReuseTokenSource
Token caching is now done whenever you make a Client, and
ReuseTokenSource is exported from the oauth2 package and used by the
Google TokenSources (Compute and App Engine).

Token.Expired is now Token.Valid, and works on nil receivers.

Some other wording cleanups in the process.

All tests pass. App Engine should pass, but is untested.

Change-Id: Ibe1d2599ac3ccfe9b399b1672f74bb24cfc8d311
Reviewed-on: https://go-review.googlesource.com/2195
Reviewed-by: Burcu Dogan <jbd@google.com>
2014-12-30 22:27:30 +00:00
Brad Fitzpatrick f5b40b26f1 oauth2: use a JSON struct types instead of empty interface maps
Change-Id: Ifd66ea35c15dbd14acca0c945b533ec755de12e4
Reviewed-on: https://go-review.googlesource.com/1872
Reviewed-by: Burcu Dogan <jbd@google.com>
2014-12-20 06:52:21 +00:00
Brad Fitzpatrick 9abe144dd5 oauth2: move Token into its own file (no code changes)
Change-Id: I5248f48cc1af68a0f78a8ddf7e28b91a729f5460
Reviewed-on: https://go-review.googlesource.com/1870
Reviewed-by: David Symonds <dsymonds@golang.org>
2014-12-19 04:29:46 +00:00
Dave Day 7bbf2199a5 oauth2: add func NewClient as per issue #66
Change-Id: Icfae8530e725f2f31774e395319e6e6db330262a
Reviewed-on: https://go-review.googlesource.com/1701
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-17 00:04:06 +00:00
Johan Euphrosine a360c4ed80 oauth2: fix typo
Change-Id: Ic39a63c50a042ab836bbc496db9aea7fb52870d2
Reviewed-on: https://go-review.googlesource.com/1652
Reviewed-by: Burcu Dogan <jbd@google.com>
2014-12-16 18:11:04 +00:00
Burcu Dogan 9b6b7610ad oauth2: rewrite google package, fix the broken build
Change-Id: I2753a88d7be483bdbc0cac09a1beccc4806ea4bc
Reviewed-on: https://go-review.googlesource.com/1361
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-16 06:20:58 +00:00
Brad Fitzpatrick a568078818 oauth2: redesign the API
Tests and examples aren't updated yet. The tree will be broken after this,
but nobody should be using this yet anyway.

Change-Id: I0004c738f40919ab46d107c71c011c510fbc748f
Reviewed-on: https://go-review.googlesource.com/1246
Reviewed-by: Burcu Dogan <jbd@google.com>
2014-12-16 06:20:49 +00:00
Andrew Gerrand 3ec35f1969 Merge branch 'master' of https://github.com/golang/oauth2 2014-11-28 10:17:23 +11:00
Burcu Dogan e750a2fd5a oauth2: add vanity URL import comments, use the vanity URL on builds
Change-Id: Ia20e40d98aa709e3d598388e0a15501584152ab5
2014-11-26 11:47:34 -08:00
Burcu Dogan 5fd31d511c Merge pull request #50 from snikch/fix-json-expiry
Handle expiry correctly in json response
2014-11-25 19:48:01 -08:00
Burcu Dogan b846388564 oauth2: Removing the inconsistent and duplicate features, better naming
- Removed Flow, flow is a nothing but options.
- Renamed Cacher to Storer.
- Removed the setter from the Transport. Store should do the initial set.
  Getter is not removed, because extra fields are available through
  Transport.Token.Extra(). It's not pleasant to implement a custom Storer
  implementation to read such values.

oauth2: Remove VMs from the AppEngine example title
2014-11-25 14:36:49 -08:00
Mal Curtis 778494f9ec Handle expiry correctly in json response
Go treats json numbers as float64 not int. Previously json response
expiry information was ignored since it was expected to be an int.
2014-11-21 13:07:44 +13:00
Burcu Dogan c048af9da2 Add Cacher interface. 2014-11-13 15:41:14 +11:00
Burcu Dogan 2d3ce25e9a Don't mutate the authorization endpoint.
Flow should be reusable, Options object should not be
mutated by the calls performed on the flow.
2014-11-12 10:02:14 +11:00
Burcu Dogan 0b8fcbadce Avoid setting an explicit token fetcher for the known flows. 2014-11-11 11:22:30 +11:00
Burcu Dogan 0cf6f9b144 Introduce an option function type
- Reduce the duplicate code by merging the flows and
determining the flow type by looking at the provided options.
- Options as a function type allows us to validate an individual
an option in its scope and makes it easier to compose the
built-in options with the third-party ones.
2014-11-08 09:46:26 +11:00
Burcu Dogan 0ae3d4edc9 Allow users to get extra fields from a token response. 2014-10-27 20:01:11 -07:00
Burcu Dogan 4b407cace1 Support token expiration for Facebook OAuth 2.0.
Facebook's OAuth 2.0 implementation seems to be broken and
returns expires_in value in expires. Fallback to expires field to
handle the expiration time for Facebook.
2014-10-21 10:43:33 -07:00
Matt Jibson 123b41c5cb Add SoundCloud to the providers not supporting Auth headers 2014-10-04 02:16:01 -04:00
Matt Jibson 311200b953 Spelling 2014-10-04 02:15:35 -04:00
CL Sung 099e4f09b0 Add Linkedin to the providers not supporting Auth headers. 2014-09-11 10:49:49 +08:00
Burcu Dogan 85a0f4506d Merge pull request #37 from stacktic/DropboxAuthFix
Add Dropbox to the providers not supporting Auth headers.
2014-09-08 09:59:12 -07:00
Arnaud Ysmal e6396819be Add Dropbox to the providers not supporting Auth headers.
Dropbox does not support mixing URL param and Auth header for authentication but the retrieveToken method forces the client_id to be sent in the URL param.
2014-09-07 19:05:03 +02:00
JT Olds e68820a209 fix token exchange 2014-09-06 17:39:43 -06:00
Burcu Dogan 97a89b3be5 Access type and approval prompt should be set at URL generation. 2014-09-04 23:30:06 -07:00
Burcu Dogan cb029f4c1f Fix error message prefix. 2014-09-04 13:33:06 -07:00
Burcu Dogan bb8496880f Don't assume optional fields are required and use Basic Auth if available.
See https://github.com/golang/oauth2/issues/33
2014-09-04 13:28:18 -07:00
Burcu Dogan 32b8a902e6 client_secret should be optional. 2014-09-04 12:03:06 -07:00