diff --git a/client.go b/client.go new file mode 100644 index 000000000..9caf87461 --- /dev/null +++ b/client.go @@ -0,0 +1,15 @@ +// +build !appengine + +package goth + +import ( + "net/http" + + "golang.org/x/net/context" +) + +// Provider implementations should use this method for making outbound HTTP +// requests. +var HTTPClient = func(ctx context.Context) (*http.Client, error) { + return http.DefaultClient, nil +} diff --git a/client_appengine.go b/client_appengine.go new file mode 100644 index 000000000..b3e0cca71 --- /dev/null +++ b/client_appengine.go @@ -0,0 +1,16 @@ +// +build appengine + +package goth + +import ( + "net/http" + + "golang.org/x/net/context" + "google.golang.org/appengine/urlfetch" +) + +// Provider implementations should use this method for making outbound HTTP +// requests. +var HTTPClient = func(ctx context.Context) (*http.Client, error) { + return urlfetch.Client(ctx), nil +} diff --git a/examples/main.go b/examples/main.go index 9d8c91054..087fde84b 100644 --- a/examples/main.go +++ b/examples/main.go @@ -10,40 +10,40 @@ import ( "github.com/gorilla/pat" "github.com/gorilla/sessions" - "github.com/markbates/goth" - "github.com/markbates/goth/gothic" - "github.com/markbates/goth/providers/amazon" - "github.com/markbates/goth/providers/bitbucket" - "github.com/markbates/goth/providers/box" - "github.com/markbates/goth/providers/dailymotion" - "github.com/markbates/goth/providers/deezer" - "github.com/markbates/goth/providers/digitalocean" - "github.com/markbates/goth/providers/discord" - "github.com/markbates/goth/providers/dropbox" - "github.com/markbates/goth/providers/facebook" - "github.com/markbates/goth/providers/fitbit" - "github.com/markbates/goth/providers/github" - "github.com/markbates/goth/providers/gitlab" - "github.com/markbates/goth/providers/gplus" - "github.com/markbates/goth/providers/heroku" - "github.com/markbates/goth/providers/instagram" - "github.com/markbates/goth/providers/intercom" - "github.com/markbates/goth/providers/lastfm" - "github.com/markbates/goth/providers/linkedin" - "github.com/markbates/goth/providers/onedrive" - "github.com/markbates/goth/providers/paypal" - "github.com/markbates/goth/providers/salesforce" - "github.com/markbates/goth/providers/slack" - "github.com/markbates/goth/providers/soundcloud" - "github.com/markbates/goth/providers/spotify" - "github.com/markbates/goth/providers/steam" - "github.com/markbates/goth/providers/stripe" - "github.com/markbates/goth/providers/twitch" - "github.com/markbates/goth/providers/twitter" - "github.com/markbates/goth/providers/uber" - "github.com/markbates/goth/providers/wepay" - "github.com/markbates/goth/providers/yahoo" - "github.com/markbates/goth/providers/yammer" + "github.com/jtolds/goth" + "github.com/jtolds/goth/gothic" + "github.com/jtolds/goth/providers/amazon" + "github.com/jtolds/goth/providers/bitbucket" + "github.com/jtolds/goth/providers/box" + "github.com/jtolds/goth/providers/dailymotion" + "github.com/jtolds/goth/providers/deezer" + "github.com/jtolds/goth/providers/digitalocean" + "github.com/jtolds/goth/providers/discord" + "github.com/jtolds/goth/providers/dropbox" + "github.com/jtolds/goth/providers/facebook" + "github.com/jtolds/goth/providers/fitbit" + "github.com/jtolds/goth/providers/github" + "github.com/jtolds/goth/providers/gitlab" + "github.com/jtolds/goth/providers/gplus" + "github.com/jtolds/goth/providers/heroku" + "github.com/jtolds/goth/providers/instagram" + "github.com/jtolds/goth/providers/intercom" + "github.com/jtolds/goth/providers/lastfm" + "github.com/jtolds/goth/providers/linkedin" + "github.com/jtolds/goth/providers/onedrive" + "github.com/jtolds/goth/providers/paypal" + "github.com/jtolds/goth/providers/salesforce" + "github.com/jtolds/goth/providers/slack" + "github.com/jtolds/goth/providers/soundcloud" + "github.com/jtolds/goth/providers/spotify" + "github.com/jtolds/goth/providers/steam" + "github.com/jtolds/goth/providers/stripe" + "github.com/jtolds/goth/providers/twitch" + "github.com/jtolds/goth/providers/twitter" + "github.com/jtolds/goth/providers/uber" + "github.com/jtolds/goth/providers/wepay" + "github.com/jtolds/goth/providers/yahoo" + "github.com/jtolds/goth/providers/yammer" ) func init() { diff --git a/gothic/gothic.go b/gothic/gothic.go index 1ac31f3af..532b22e3e 100644 --- a/gothic/gothic.go +++ b/gothic/gothic.go @@ -3,7 +3,7 @@ Package gothic wraps common behaviour when using Goth. This makes it quick, and and running with Goth. Of course, if you want complete control over how things flow, in regards to the authentication process, feel free and use Goth directly. -See https://github.com/markbates/goth/examples/main.go to see this in action. +See https://github.com/jtolds/goth/examples/main.go to see this in action. */ package gothic @@ -15,7 +15,7 @@ import ( "github.com/gorilla/mux" "github.com/gorilla/sessions" - "github.com/markbates/goth" + "github.com/jtolds/goth" ) // SessionName is the key used to access the session store. @@ -42,7 +42,7 @@ as either "provider" or ":provider". BeginAuthHandler will redirect the user to the appropriate authentication end-point for the requested provider. -See https://github.com/markbates/goth/examples/main.go to see this in action. +See https://github.com/jtolds/goth/examples/main.go to see this in action. */ func BeginAuthHandler(res http.ResponseWriter, req *http.Request) { url, err := GetAuthURL(res, req) @@ -128,7 +128,7 @@ process and fetches all of the basic information about the user from the provide It expects to be able to get the name of the provider from the query parameters as either "provider" or ":provider". -See https://github.com/markbates/goth/examples/main.go to see this in action. +See https://github.com/jtolds/goth/examples/main.go to see this in action. */ var CompleteUserAuth = func(res http.ResponseWriter, req *http.Request) (goth.User, error) { diff --git a/gothic/gothic_test.go b/gothic/gothic_test.go index a635e6cae..7176e2f80 100644 --- a/gothic/gothic_test.go +++ b/gothic/gothic_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/gorilla/sessions" - "github.com/markbates/goth" - . "github.com/markbates/goth/gothic" - "github.com/markbates/goth/providers/faux" + "github.com/jtolds/goth" + . "github.com/jtolds/goth/gothic" + "github.com/jtolds/goth/providers/faux" "github.com/stretchr/testify/assert" ) diff --git a/provider.go b/provider.go index 568fdc6ec..a629a0b1c 100644 --- a/provider.go +++ b/provider.go @@ -1,18 +1,34 @@ package goth -import "fmt" -import "golang.org/x/oauth2" +import ( + "fmt" + + "golang.org/x/net/context" + "golang.org/x/oauth2" +) // Provider needs to be implemented for each 3rd party authentication provider // e.g. Facebook, Twitter, etc... type Provider interface { + // When implementing a provider, these methods should not make outbound + // requests. Name() string - BeginAuth(state string) (Session, error) UnmarshalSession(string) (Session, error) - FetchUser(Session) (User, error) Debug(bool) - RefreshToken(refreshToken string) (*oauth2.Token, error) //Get new access token based on the refresh token - RefreshTokenAvailable() bool //Refresh token is provided by auth provider or not + // Refresh token is provided by auth provider or not + RefreshTokenAvailable() bool + + // These three methods are deprecated. See the appropriate *Ctx replacement. + BeginAuth(state string) (Session, error) + FetchUser(Session) (User, error) + RefreshToken(refreshToken string) (*oauth2.Token, error) + + // These methods are now preferred. + BeginAuthCtx(ctx context.Context, state string) (Session, error) + FetchUserCtx(context.Context, Session) (User, error) + // Get new access token based on the refresh token. + // Only works if RefreshTokenAvailable() is true + RefreshTokenCtx(ctx context.Context, refreshToken string) (*oauth2.Token, error) } // Providers is list of known/available providers. diff --git a/provider_test.go b/provider_test.go index b7acceca2..862ee4a43 100644 --- a/provider_test.go +++ b/provider_test.go @@ -3,8 +3,8 @@ package goth_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/faux" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/faux" "github.com/stretchr/testify/assert" ) diff --git a/providers/amazon/amazon.go b/providers/amazon/amazon.go index dfb370200..620f47615 100644 --- a/providers/amazon/amazon.go +++ b/providers/amazon/amazon.go @@ -5,7 +5,7 @@ package amazon import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/amazon/amazon_test.go b/providers/amazon/amazon_test.go index 59a0fc1b9..3660ff68a 100644 --- a/providers/amazon/amazon_test.go +++ b/providers/amazon/amazon_test.go @@ -1,8 +1,8 @@ package amazon_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/amazon" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/amazon" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/amazon/session.go b/providers/amazon/session.go index f9220d7f7..ee974a957 100644 --- a/providers/amazon/session.go +++ b/providers/amazon/session.go @@ -3,7 +3,7 @@ package amazon import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/amazon/session_test.go b/providers/amazon/session_test.go index 101fb2654..47f6433a3 100644 --- a/providers/amazon/session_test.go +++ b/providers/amazon/session_test.go @@ -1,8 +1,8 @@ package amazon_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/amazon" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/amazon" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/bitbucket/bitbucket.go b/providers/bitbucket/bitbucket.go index 5c0b51bec..64178edfd 100644 --- a/providers/bitbucket/bitbucket.go +++ b/providers/bitbucket/bitbucket.go @@ -4,7 +4,7 @@ package bitbucket import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/bitbucket/bitbucket_test.go b/providers/bitbucket/bitbucket_test.go index 22c8db3d3..7c898b2b6 100644 --- a/providers/bitbucket/bitbucket_test.go +++ b/providers/bitbucket/bitbucket_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/bitbucket" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/bitbucket" "github.com/stretchr/testify/assert" ) diff --git a/providers/bitbucket/session.go b/providers/bitbucket/session.go index 3ccbd6497..e94a82e08 100644 --- a/providers/bitbucket/session.go +++ b/providers/bitbucket/session.go @@ -3,7 +3,7 @@ package bitbucket import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/bitbucket/session_test.go b/providers/bitbucket/session_test.go index ac181a775..6f0127045 100644 --- a/providers/bitbucket/session_test.go +++ b/providers/bitbucket/session_test.go @@ -3,8 +3,8 @@ package bitbucket_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/bitbucket" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/bitbucket" "github.com/stretchr/testify/assert" ) diff --git a/providers/box/box.go b/providers/box/box.go index 62d1f26c7..4ddbecfc8 100644 --- a/providers/box/box.go +++ b/providers/box/box.go @@ -4,7 +4,7 @@ package box import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/box/box_test.go b/providers/box/box_test.go index 8111da0e5..5c55b76f0 100644 --- a/providers/box/box_test.go +++ b/providers/box/box_test.go @@ -1,8 +1,8 @@ package box_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/box" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/box" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/box/session.go b/providers/box/session.go index 758df950c..825ee5070 100644 --- a/providers/box/session.go +++ b/providers/box/session.go @@ -3,7 +3,7 @@ package box import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/box/session_test.go b/providers/box/session_test.go index bf562d400..dfe8cb25a 100644 --- a/providers/box/session_test.go +++ b/providers/box/session_test.go @@ -1,8 +1,8 @@ package box_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/box" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/box" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/cloudfoundry/cf.go b/providers/cloudfoundry/cf.go index 5a547b140..c7995be0a 100644 --- a/providers/cloudfoundry/cf.go +++ b/providers/cloudfoundry/cf.go @@ -10,7 +10,7 @@ import ( "net/http" "strings" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/net/context" "golang.org/x/oauth2" ) diff --git a/providers/cloudfoundry/cf_test.go b/providers/cloudfoundry/cf_test.go index 44a7d5e9b..5d0e7b26e 100644 --- a/providers/cloudfoundry/cf_test.go +++ b/providers/cloudfoundry/cf_test.go @@ -1,8 +1,8 @@ package cloudfoundry_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/cloudfoundry" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/cloudfoundry" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/cloudfoundry/session.go b/providers/cloudfoundry/session.go index 942b29d82..56f60292f 100644 --- a/providers/cloudfoundry/session.go +++ b/providers/cloudfoundry/session.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/net/context" "golang.org/x/oauth2" ) diff --git a/providers/cloudfoundry/session_test.go b/providers/cloudfoundry/session_test.go index 58b02c309..78f79cc2a 100644 --- a/providers/cloudfoundry/session_test.go +++ b/providers/cloudfoundry/session_test.go @@ -1,8 +1,8 @@ package cloudfoundry_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/cloudfoundry" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/cloudfoundry" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/dailymotion/dailymotion.go b/providers/dailymotion/dailymotion.go index 7711508b8..c9df138fc 100644 --- a/providers/dailymotion/dailymotion.go +++ b/providers/dailymotion/dailymotion.go @@ -10,7 +10,7 @@ import ( "net/http" "net/url" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" ) diff --git a/providers/dailymotion/dailymotion_test.go b/providers/dailymotion/dailymotion_test.go index 9b239f6b5..6ecb3c44d 100644 --- a/providers/dailymotion/dailymotion_test.go +++ b/providers/dailymotion/dailymotion_test.go @@ -4,8 +4,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/dailymotion" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/dailymotion" "github.com/stretchr/testify/assert" ) diff --git a/providers/dailymotion/session.go b/providers/dailymotion/session.go index 9832b0439..d26ca565d 100644 --- a/providers/dailymotion/session.go +++ b/providers/dailymotion/session.go @@ -3,7 +3,7 @@ package dailymotion import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/dailymotion/session_test.go b/providers/dailymotion/session_test.go index 622224402..6a85a20cc 100644 --- a/providers/dailymotion/session_test.go +++ b/providers/dailymotion/session_test.go @@ -1,8 +1,8 @@ package dailymotion_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/dailymotion" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/dailymotion" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/deezer/deezer.go b/providers/deezer/deezer.go index 7679dfdea..be1326d43 100644 --- a/providers/deezer/deezer.go +++ b/providers/deezer/deezer.go @@ -11,7 +11,7 @@ import ( "net/http" "net/url" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" ) diff --git a/providers/deezer/deezer_test.go b/providers/deezer/deezer_test.go index e471620e5..27ec36708 100644 --- a/providers/deezer/deezer_test.go +++ b/providers/deezer/deezer_test.go @@ -4,8 +4,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/deezer" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/deezer" "github.com/stretchr/testify/assert" ) diff --git a/providers/deezer/session.go b/providers/deezer/session.go index 2fe02db8d..a9e50cec1 100644 --- a/providers/deezer/session.go +++ b/providers/deezer/session.go @@ -3,7 +3,7 @@ package deezer import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/deezer/session_test.go b/providers/deezer/session_test.go index 6834cd284..26fcabfe8 100644 --- a/providers/deezer/session_test.go +++ b/providers/deezer/session_test.go @@ -1,8 +1,8 @@ package deezer_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/deezer" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/deezer" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/digitalocean/digitalocean.go b/providers/digitalocean/digitalocean.go index 0bc941e3b..1ca336316 100644 --- a/providers/digitalocean/digitalocean.go +++ b/providers/digitalocean/digitalocean.go @@ -3,7 +3,7 @@ package digitalocean import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/digitalocean/digitalocean_test.go b/providers/digitalocean/digitalocean_test.go index ff2c0daec..9d635dd58 100644 --- a/providers/digitalocean/digitalocean_test.go +++ b/providers/digitalocean/digitalocean_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/markbates/goth/providers/digitalocean" + "github.com/jtolds/goth/providers/digitalocean" "github.com/stretchr/testify/assert" ) diff --git a/providers/digitalocean/session.go b/providers/digitalocean/session.go index de2eff4a4..1bc9e0e77 100644 --- a/providers/digitalocean/session.go +++ b/providers/digitalocean/session.go @@ -3,7 +3,7 @@ package digitalocean import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/digitalocean/session_test.go b/providers/digitalocean/session_test.go index 7970440df..b50855a23 100644 --- a/providers/digitalocean/session_test.go +++ b/providers/digitalocean/session_test.go @@ -3,7 +3,7 @@ package digitalocean_test import ( "testing" - "github.com/markbates/goth/providers/digitalocean" + "github.com/jtolds/goth/providers/digitalocean" "github.com/stretchr/testify/assert" ) diff --git a/providers/discord/discord.go b/providers/discord/discord.go index a39e2bac0..d99af8961 100644 --- a/providers/discord/discord.go +++ b/providers/discord/discord.go @@ -5,7 +5,7 @@ package discord import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/discord/discord_test.go b/providers/discord/discord_test.go index ccdfb8cf2..f9897e969 100644 --- a/providers/discord/discord_test.go +++ b/providers/discord/discord_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/discord/session.go b/providers/discord/session.go index a07cc99bf..023925b69 100644 --- a/providers/discord/session.go +++ b/providers/discord/session.go @@ -3,7 +3,7 @@ package discord import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/discord/session_test.go b/providers/discord/session_test.go index ee412e7e9..93573382f 100644 --- a/providers/discord/session_test.go +++ b/providers/discord/session_test.go @@ -3,7 +3,7 @@ package discord import ( "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/dropbox/dropbox.go b/providers/dropbox/dropbox.go index fe19a014e..53b02b9fb 100644 --- a/providers/dropbox/dropbox.go +++ b/providers/dropbox/dropbox.go @@ -4,7 +4,7 @@ package dropbox import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/dropbox/dropbox_test.go b/providers/dropbox/dropbox_test.go index 3fdc607df..3330aaebc 100644 --- a/providers/dropbox/dropbox_test.go +++ b/providers/dropbox/dropbox_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/facebook/facebook.go b/providers/facebook/facebook.go index 75f2ea543..32c471636 100644 --- a/providers/facebook/facebook.go +++ b/providers/facebook/facebook.go @@ -8,10 +8,10 @@ import ( "errors" "io" "io/ioutil" - "net/http" "net/url" - "github.com/markbates/goth" + "github.com/jtolds/goth" + "golang.org/x/net/context" "golang.org/x/oauth2" ) @@ -50,8 +50,12 @@ func (p *Provider) Name() string { // Debug is a no-op for the facebook package. func (p *Provider) Debug(debug bool) {} -// BeginAuth asks Facebook for an authentication end-point. func (p *Provider) BeginAuth(state string) (goth.Session, error) { + return p.BeginAuthCtx(context.TODO(), state) +} + +// BeginAuthCtx asks Facebook for an authentication end-point. +func (p *Provider) BeginAuthCtx(ctx context.Context, state string) (goth.Session, error) { url := p.config.AuthCodeURL(state) session := &Session{ AuthURL: url, @@ -59,8 +63,13 @@ func (p *Provider) BeginAuth(state string) (goth.Session, error) { return session, nil } -// FetchUser will go to Facebook and access basic information about the user. func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { + return p.FetchUserCtx(context.TODO(), session) +} + +// FetchUserCtx will go to Facebook and access basic information about the user. +func (p *Provider) FetchUserCtx(ctx context.Context, session goth.Session) ( + goth.User, error) { sess := session.(*Session) user := goth.User{ AccessToken: sess.AccessToken, @@ -68,7 +77,12 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { ExpiresAt: sess.ExpiresAt, } - response, err := http.Get(endpointProfile + "&access_token=" + url.QueryEscape(sess.AccessToken)) + client, err := goth.HTTPClient(ctx) + if err != nil { + return user, err + } + + response, err := client.Get(endpointProfile + "&access_token=" + url.QueryEscape(sess.AccessToken)) if err != nil { return user, err } @@ -152,12 +166,16 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config { return c } -//RefreshToken refresh token is not provided by facebook func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) { + return p.RefreshTokenCtx(context.TODO(), refreshToken) +} + +// RefreshTokenCtx refresh token is not provided by facebook +func (p *Provider) RefreshTokenCtx(ctx context.Context, refreshToken string) (*oauth2.Token, error) { return nil, errors.New("Refresh token is not provided by facebook") } -//RefreshTokenAvailable refresh token is not provided by facebook +// RefreshTokenAvailable refresh token is not provided by facebook func (p *Provider) RefreshTokenAvailable() bool { return false } diff --git a/providers/facebook/facebook_test.go b/providers/facebook/facebook_test.go index adf00ab41..2e28a52f6 100644 --- a/providers/facebook/facebook_test.go +++ b/providers/facebook/facebook_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/facebook" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/facebook" "github.com/stretchr/testify/assert" ) diff --git a/providers/facebook/session.go b/providers/facebook/session.go index b0a651784..0bc7144eb 100644 --- a/providers/facebook/session.go +++ b/providers/facebook/session.go @@ -3,10 +3,11 @@ package facebook import ( "encoding/json" "errors" - "github.com/markbates/goth" - "golang.org/x/oauth2" "strings" "time" + + "github.com/jtolds/goth" + "golang.org/x/net/context" ) // Session stores data during the auth process with Facebook. @@ -24,10 +25,14 @@ func (s Session) GetAuthURL() (string, error) { return s.AuthURL, nil } -// Authorize the session with Facebook and return the access token to be stored for future use. func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { + return s.AuthorizeCtx(context.TODO(), provider, params) +} + +// AuthorizeCtx the session with Facebook and return the access token to be stored for future use. +func (s *Session) AuthorizeCtx(ctx context.Context, provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) - token, err := p.config.Exchange(oauth2.NoContext, params.Get("code")) + token, err := p.config.Exchange(ctx, params.Get("code")) if err != nil { return "", err } diff --git a/providers/facebook/session_test.go b/providers/facebook/session_test.go index 0b709a16a..ba621e815 100644 --- a/providers/facebook/session_test.go +++ b/providers/facebook/session_test.go @@ -3,8 +3,8 @@ package facebook_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/facebook" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/facebook" "github.com/stretchr/testify/assert" ) diff --git a/providers/faux/faux.go b/providers/faux/faux.go index c0f4e96a8..ec672071e 100644 --- a/providers/faux/faux.go +++ b/providers/faux/faux.go @@ -4,7 +4,7 @@ package faux import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" ) diff --git a/providers/fitbit/fitbit.go b/providers/fitbit/fitbit.go index 3fc9713ff..bdd0d7c81 100644 --- a/providers/fitbit/fitbit.go +++ b/providers/fitbit/fitbit.go @@ -7,7 +7,7 @@ import ( "io" "net/http" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" ) diff --git a/providers/fitbit/fitbit_test.go b/providers/fitbit/fitbit_test.go index 25e788b88..6f20f24cb 100644 --- a/providers/fitbit/fitbit_test.go +++ b/providers/fitbit/fitbit_test.go @@ -4,8 +4,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/fitbit" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/fitbit" "github.com/stretchr/testify/assert" ) diff --git a/providers/fitbit/session.go b/providers/fitbit/session.go index 345f295f4..4e4756768 100644 --- a/providers/fitbit/session.go +++ b/providers/fitbit/session.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" ) diff --git a/providers/fitbit/session_test.go b/providers/fitbit/session_test.go index 54c97739e..40b3a09fc 100644 --- a/providers/fitbit/session_test.go +++ b/providers/fitbit/session_test.go @@ -3,8 +3,8 @@ package fitbit_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/fitbit" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/fitbit" "github.com/stretchr/testify/assert" ) diff --git a/providers/github/github.go b/providers/github/github.go index 46d810d3c..1d9e67dc0 100644 --- a/providers/github/github.go +++ b/providers/github/github.go @@ -14,7 +14,7 @@ import ( "strconv" "strings" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" ) diff --git a/providers/github/github_test.go b/providers/github/github_test.go index c79f86010..cfa2aaf63 100644 --- a/providers/github/github_test.go +++ b/providers/github/github_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/github" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/github" "github.com/stretchr/testify/assert" ) diff --git a/providers/github/session.go b/providers/github/session.go index fd7a8481b..c731f3c09 100644 --- a/providers/github/session.go +++ b/providers/github/session.go @@ -3,7 +3,7 @@ package github import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" ) diff --git a/providers/github/session_test.go b/providers/github/session_test.go index 5241f9d43..9ffc58f0a 100644 --- a/providers/github/session_test.go +++ b/providers/github/session_test.go @@ -3,8 +3,8 @@ package github_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/github" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/github" "github.com/stretchr/testify/assert" ) diff --git a/providers/gitlab/gitlab.go b/providers/gitlab/gitlab.go index bb6e6c5c1..7beb068f3 100644 --- a/providers/gitlab/gitlab.go +++ b/providers/gitlab/gitlab.go @@ -5,7 +5,7 @@ package gitlab import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/gitlab/gitlab_test.go b/providers/gitlab/gitlab_test.go index 1cbc4ed6c..36ea29d33 100644 --- a/providers/gitlab/gitlab_test.go +++ b/providers/gitlab/gitlab_test.go @@ -1,8 +1,8 @@ package gitlab_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/gitlab" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/gitlab" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/gitlab/session.go b/providers/gitlab/session.go index bfa5c9984..96a88394f 100644 --- a/providers/gitlab/session.go +++ b/providers/gitlab/session.go @@ -3,7 +3,7 @@ package gitlab import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/gitlab/session_test.go b/providers/gitlab/session_test.go index 9939d1475..c27469e08 100644 --- a/providers/gitlab/session_test.go +++ b/providers/gitlab/session_test.go @@ -1,8 +1,8 @@ package gitlab_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/gitlab" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/gitlab" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/gplus/gplus.go b/providers/gplus/gplus.go index 4e1dbe0fa..046801dc1 100644 --- a/providers/gplus/gplus.go +++ b/providers/gplus/gplus.go @@ -7,11 +7,11 @@ import ( "encoding/json" "io" "io/ioutil" - "net/http" "net/url" "strings" - "github.com/markbates/goth" + "github.com/jtolds/goth" + "golang.org/x/net/context" "golang.org/x/oauth2" ) @@ -51,8 +51,12 @@ func (p *Provider) Name() string { // Debug is a no-op for the gplus package. func (p *Provider) Debug(debug bool) {} -// BeginAuth asks Google+ for an authentication end-point. func (p *Provider) BeginAuth(state string) (goth.Session, error) { + return p.BeginAuthCtx(context.TODO(), state) +} + +// BeginAuthCtx asks Google+ for an authentication end-point. +func (p *Provider) BeginAuthCtx(ctx context.Context, state string) (goth.Session, error) { var opts []oauth2.AuthCodeOption if p.prompt != nil { opts = append(opts, p.prompt) @@ -64,8 +68,14 @@ func (p *Provider) BeginAuth(state string) (goth.Session, error) { return session, nil } -// FetchUser will go to Google+ and access basic information about the user. -func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { +func (p *Provider) FetchUser(session goth.Session) ( + goth.User, error) { + return p.FetchUserCtx(context.TODO(), session) +} + +// FetchUserCtx will go to Google+ and access basic information about the user. +func (p *Provider) FetchUserCtx(ctx context.Context, session goth.Session) ( + goth.User, error) { sess := session.(*Session) user := goth.User{ AccessToken: sess.AccessToken, @@ -74,7 +84,12 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { ExpiresAt: sess.ExpiresAt, } - response, err := http.Get(endpointProfile + "?access_token=" + url.QueryEscape(sess.AccessToken)) + client, err := goth.HTTPClient(ctx) + if err != nil { + return user, err + } + + response, err := client.Get(endpointProfile + "?access_token=" + url.QueryEscape(sess.AccessToken)) if err != nil { return user, err } @@ -145,15 +160,21 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config { return c } -//RefreshTokenAvailable refresh token is provided by auth provider or not +// RefreshTokenAvailable refresh token is provided by auth provider or not func (p *Provider) RefreshTokenAvailable() bool { return true } -//RefreshToken get new access token based on the refresh token -func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) { +func (p *Provider) RefreshToken(refreshToken string) ( + *oauth2.Token, error) { + return p.RefreshTokenCtx(context.TODO(), refreshToken) +} + +// RefreshTokenCtx get new access token based on the refresh token +func (p *Provider) RefreshTokenCtx(ctx context.Context, refreshToken string) ( + *oauth2.Token, error) { token := &oauth2.Token{RefreshToken: refreshToken} - ts := p.config.TokenSource(oauth2.NoContext, token) + ts := p.config.TokenSource(ctx, token) newToken, err := ts.Token() if err != nil { return nil, err diff --git a/providers/gplus/gplus_test.go b/providers/gplus/gplus_test.go index f5a3abfb9..48e84bbb8 100644 --- a/providers/gplus/gplus_test.go +++ b/providers/gplus/gplus_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/gplus" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/gplus" "github.com/stretchr/testify/assert" ) diff --git a/providers/gplus/session.go b/providers/gplus/session.go index c1372d6d7..e8eb771b0 100644 --- a/providers/gplus/session.go +++ b/providers/gplus/session.go @@ -3,10 +3,11 @@ package gplus import ( "encoding/json" "errors" - "github.com/markbates/goth" - "golang.org/x/oauth2" "strings" "time" + + "github.com/jtolds/goth" + "golang.org/x/net/context" ) // Session stores data during the auth process with Facebook. @@ -25,10 +26,14 @@ func (s Session) GetAuthURL() (string, error) { return s.AuthURL, nil } -// Authorize the session with Google+ and return the access token to be stored for future use. func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { + return s.AuthorizeCtx(context.TODO(), provider, params) +} + +// AuthorizeCtx the session with Google+ and return the access token to be stored for future use. +func (s *Session) AuthorizeCtx(ctx context.Context, provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) - token, err := p.config.Exchange(oauth2.NoContext, params.Get("code")) + token, err := p.config.Exchange(ctx, params.Get("code")) if err != nil { return "", err } diff --git a/providers/gplus/session_test.go b/providers/gplus/session_test.go index 9308c977d..3df921c75 100644 --- a/providers/gplus/session_test.go +++ b/providers/gplus/session_test.go @@ -3,7 +3,7 @@ package gplus import ( "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/heroku/heroku.go b/providers/heroku/heroku.go index 85e18f220..08379d170 100644 --- a/providers/heroku/heroku.go +++ b/providers/heroku/heroku.go @@ -4,7 +4,7 @@ package heroku import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/heroku/heroku_test.go b/providers/heroku/heroku_test.go index 336f2e9b8..43ee76302 100644 --- a/providers/heroku/heroku_test.go +++ b/providers/heroku/heroku_test.go @@ -1,8 +1,8 @@ package heroku_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/heroku" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/heroku" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/heroku/session.go b/providers/heroku/session.go index fbc00d53f..3ae0f91bb 100644 --- a/providers/heroku/session.go +++ b/providers/heroku/session.go @@ -3,7 +3,7 @@ package heroku import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/heroku/session_test.go b/providers/heroku/session_test.go index 1a66e26be..c17c45eb1 100644 --- a/providers/heroku/session_test.go +++ b/providers/heroku/session_test.go @@ -1,8 +1,8 @@ package heroku_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/heroku" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/heroku" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/influxcloud/influxcloud.go b/providers/influxcloud/influxcloud.go index 072cc5ff6..c472bf79b 100644 --- a/providers/influxcloud/influxcloud.go +++ b/providers/influxcloud/influxcloud.go @@ -14,7 +14,7 @@ import ( "os" "strconv" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" ) diff --git a/providers/influxcloud/influxcloud_test.go b/providers/influxcloud/influxcloud_test.go index 0aa7a8346..d059d3920 100644 --- a/providers/influxcloud/influxcloud_test.go +++ b/providers/influxcloud/influxcloud_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/influxcloud/session.go b/providers/influxcloud/session.go index 4625def20..6190f2822 100644 --- a/providers/influxcloud/session.go +++ b/providers/influxcloud/session.go @@ -5,7 +5,7 @@ import ( "errors" "strings" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" ) diff --git a/providers/influxcloud/session_test.go b/providers/influxcloud/session_test.go index bf7eed84c..9f735d9a2 100644 --- a/providers/influxcloud/session_test.go +++ b/providers/influxcloud/session_test.go @@ -3,8 +3,8 @@ package influxcloud_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/influxcloud" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/influxcloud" "github.com/stretchr/testify/assert" ) diff --git a/providers/instagram/instagram.go b/providers/instagram/instagram.go index 7c7b1522c..229363599 100644 --- a/providers/instagram/instagram.go +++ b/providers/instagram/instagram.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/instagram/instagram_test.go b/providers/instagram/instagram_test.go index c95b62ddd..8e7494a47 100644 --- a/providers/instagram/instagram_test.go +++ b/providers/instagram/instagram_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/instagram" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/instagram" "github.com/stretchr/testify/assert" ) diff --git a/providers/instagram/session.go b/providers/instagram/session.go index 3d9fef025..64291fbcb 100644 --- a/providers/instagram/session.go +++ b/providers/instagram/session.go @@ -3,7 +3,7 @@ package instagram import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" ) diff --git a/providers/instagram/session_test.go b/providers/instagram/session_test.go index 174e7c703..a51b2cca4 100644 --- a/providers/instagram/session_test.go +++ b/providers/instagram/session_test.go @@ -3,8 +3,8 @@ package instagram_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/instagram" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/instagram" "github.com/stretchr/testify/assert" ) diff --git a/providers/intercom/intercom.go b/providers/intercom/intercom.go index ce9e51068..2b4e6b293 100644 --- a/providers/intercom/intercom.go +++ b/providers/intercom/intercom.go @@ -6,7 +6,7 @@ import ( "encoding/json" "errors" "fmt" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/intercom/intercom_test.go b/providers/intercom/intercom_test.go index 0a4f31cc1..d1f0d3856 100644 --- a/providers/intercom/intercom_test.go +++ b/providers/intercom/intercom_test.go @@ -2,8 +2,8 @@ package intercom_test import ( "fmt" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/intercom" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/intercom" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/intercom/session.go b/providers/intercom/session.go index 2b3bfd609..32b00d4b1 100644 --- a/providers/intercom/session.go +++ b/providers/intercom/session.go @@ -3,7 +3,7 @@ package intercom import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/intercom/session_test.go b/providers/intercom/session_test.go index 0445e2b74..a05c345e1 100644 --- a/providers/intercom/session_test.go +++ b/providers/intercom/session_test.go @@ -1,8 +1,8 @@ package intercom_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/intercom" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/intercom" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/lastfm/lastfm.go b/providers/lastfm/lastfm.go index 77655dd85..2e0e9cfb2 100644 --- a/providers/lastfm/lastfm.go +++ b/providers/lastfm/lastfm.go @@ -8,7 +8,7 @@ import ( "encoding/xml" "errors" "fmt" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io/ioutil" "net/http" diff --git a/providers/lastfm/lastfm_test.go b/providers/lastfm/lastfm_test.go index 31154354d..aa7979a97 100644 --- a/providers/lastfm/lastfm_test.go +++ b/providers/lastfm/lastfm_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/lastfm/session.go b/providers/lastfm/session.go index 3c49aeb20..29a44493b 100644 --- a/providers/lastfm/session.go +++ b/providers/lastfm/session.go @@ -3,7 +3,7 @@ package lastfm import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "strings" ) diff --git a/providers/lastfm/session_test.go b/providers/lastfm/session_test.go index f90ec61c3..c857173ca 100644 --- a/providers/lastfm/session_test.go +++ b/providers/lastfm/session_test.go @@ -3,7 +3,7 @@ package lastfm import ( "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/linkedin/linkedin.go b/providers/linkedin/linkedin.go index 165d878ea..e81cb3182 100644 --- a/providers/linkedin/linkedin.go +++ b/providers/linkedin/linkedin.go @@ -4,7 +4,7 @@ package linkedin import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/linkedin/linkedin_test.go b/providers/linkedin/linkedin_test.go index d746f7bb3..c5a8a6b8c 100644 --- a/providers/linkedin/linkedin_test.go +++ b/providers/linkedin/linkedin_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/linkedin" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/linkedin" "github.com/stretchr/testify/assert" ) diff --git a/providers/linkedin/session.go b/providers/linkedin/session.go index 02ab55833..ff13d8fa3 100644 --- a/providers/linkedin/session.go +++ b/providers/linkedin/session.go @@ -3,7 +3,7 @@ package linkedin import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "time" ) diff --git a/providers/linkedin/session_test.go b/providers/linkedin/session_test.go index 4cd49c22a..a02267ebc 100644 --- a/providers/linkedin/session_test.go +++ b/providers/linkedin/session_test.go @@ -3,8 +3,8 @@ package linkedin_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/linkedin" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/linkedin" "github.com/stretchr/testify/assert" ) diff --git a/providers/onedrive/onedrive.go b/providers/onedrive/onedrive.go index 58bdc2882..e3d0f6a5b 100644 --- a/providers/onedrive/onedrive.go +++ b/providers/onedrive/onedrive.go @@ -5,7 +5,7 @@ package onedrive import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/onedrive/onedrive_test.go b/providers/onedrive/onedrive_test.go index 0aeb923c8..553795e99 100644 --- a/providers/onedrive/onedrive_test.go +++ b/providers/onedrive/onedrive_test.go @@ -1,8 +1,8 @@ package onedrive_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/onedrive" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/onedrive" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/onedrive/session.go b/providers/onedrive/session.go index 41134e981..cb89ae291 100644 --- a/providers/onedrive/session.go +++ b/providers/onedrive/session.go @@ -3,7 +3,7 @@ package onedrive import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/onedrive/session_test.go b/providers/onedrive/session_test.go index df507a71b..937266bbb 100644 --- a/providers/onedrive/session_test.go +++ b/providers/onedrive/session_test.go @@ -1,8 +1,8 @@ package onedrive_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/onedrive" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/onedrive" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/paypal/paypal.go b/providers/paypal/paypal.go index b1374fdac..1c4fd6658 100644 --- a/providers/paypal/paypal.go +++ b/providers/paypal/paypal.go @@ -5,7 +5,7 @@ package paypal import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/paypal/paypal_test.go b/providers/paypal/paypal_test.go index ad0f98af2..38982afaf 100644 --- a/providers/paypal/paypal_test.go +++ b/providers/paypal/paypal_test.go @@ -1,8 +1,8 @@ package paypal_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/paypal" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/paypal" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/paypal/session.go b/providers/paypal/session.go index 1cf326c27..46b9f656c 100644 --- a/providers/paypal/session.go +++ b/providers/paypal/session.go @@ -3,7 +3,7 @@ package paypal import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/paypal/session_test.go b/providers/paypal/session_test.go index fd6fc4766..b88c13957 100644 --- a/providers/paypal/session_test.go +++ b/providers/paypal/session_test.go @@ -1,8 +1,8 @@ package paypal_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/paypal" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/paypal" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/salesforce/salesforce.go b/providers/salesforce/salesforce.go index ef0e76b18..f1a5de9e4 100644 --- a/providers/salesforce/salesforce.go +++ b/providers/salesforce/salesforce.go @@ -4,7 +4,7 @@ package salesforce import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/salesforce/salesforce_test.go b/providers/salesforce/salesforce_test.go index b5096e050..779df7c64 100644 --- a/providers/salesforce/salesforce_test.go +++ b/providers/salesforce/salesforce_test.go @@ -1,8 +1,8 @@ package salesforce_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/salesforce" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/salesforce" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/salesforce/session.go b/providers/salesforce/session.go index 3c97943c1..4d554db54 100644 --- a/providers/salesforce/session.go +++ b/providers/salesforce/session.go @@ -3,7 +3,7 @@ package salesforce import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" ) diff --git a/providers/salesforce/session_test.go b/providers/salesforce/session_test.go index 2ed0f8382..beb0da3fa 100644 --- a/providers/salesforce/session_test.go +++ b/providers/salesforce/session_test.go @@ -1,8 +1,8 @@ package salesforce_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/salesforce" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/salesforce" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/slack/session.go b/providers/slack/session.go index 3e7e734d6..df6b8bc50 100644 --- a/providers/slack/session.go +++ b/providers/slack/session.go @@ -3,7 +3,7 @@ package slack import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/slack/session_test.go b/providers/slack/session_test.go index 0b57b179e..39ccacf4a 100644 --- a/providers/slack/session_test.go +++ b/providers/slack/session_test.go @@ -1,8 +1,8 @@ package slack_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/slack" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/slack" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/slack/slack.go b/providers/slack/slack.go index 08b218d44..3f43910cf 100644 --- a/providers/slack/slack.go +++ b/providers/slack/slack.go @@ -5,7 +5,7 @@ package slack import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/slack/slack_test.go b/providers/slack/slack_test.go index eda5c7592..c0319afff 100644 --- a/providers/slack/slack_test.go +++ b/providers/slack/slack_test.go @@ -1,8 +1,8 @@ package slack_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/slack" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/slack" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/soundcloud/session.go b/providers/soundcloud/session.go index a50dd66eb..2b3f7f0f9 100644 --- a/providers/soundcloud/session.go +++ b/providers/soundcloud/session.go @@ -3,7 +3,7 @@ package soundcloud import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/soundcloud/session_test.go b/providers/soundcloud/session_test.go index b62107908..2c5e8cfb5 100644 --- a/providers/soundcloud/session_test.go +++ b/providers/soundcloud/session_test.go @@ -1,8 +1,8 @@ package soundcloud_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/soundcloud" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/soundcloud" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/soundcloud/soundcloud.go b/providers/soundcloud/soundcloud.go index fa6ef5ac2..eaa0fe158 100644 --- a/providers/soundcloud/soundcloud.go +++ b/providers/soundcloud/soundcloud.go @@ -5,7 +5,7 @@ package soundcloud import ( "bytes" "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "io/ioutil" diff --git a/providers/soundcloud/soundcloud_test.go b/providers/soundcloud/soundcloud_test.go index c17ab17f7..5f5377346 100644 --- a/providers/soundcloud/soundcloud_test.go +++ b/providers/soundcloud/soundcloud_test.go @@ -1,8 +1,8 @@ package soundcloud_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/soundcloud" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/soundcloud" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/spotify/session.go b/providers/spotify/session.go index 2b41da7db..d1ee35814 100644 --- a/providers/spotify/session.go +++ b/providers/spotify/session.go @@ -3,7 +3,7 @@ package spotify import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "time" ) diff --git a/providers/spotify/session_test.go b/providers/spotify/session_test.go index 42abfc453..9f2901cf9 100644 --- a/providers/spotify/session_test.go +++ b/providers/spotify/session_test.go @@ -3,8 +3,8 @@ package spotify_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/spotify" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/spotify" "github.com/stretchr/testify/assert" ) diff --git a/providers/spotify/spotify.go b/providers/spotify/spotify.go index 935179578..70afec6cc 100644 --- a/providers/spotify/spotify.go +++ b/providers/spotify/spotify.go @@ -4,7 +4,7 @@ package spotify import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/spotify/spotify_test.go b/providers/spotify/spotify_test.go index 5d65e9ce9..fe3b503fa 100644 --- a/providers/spotify/spotify_test.go +++ b/providers/spotify/spotify_test.go @@ -4,8 +4,8 @@ import ( "os" "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/spotify" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/spotify" "github.com/stretchr/testify/assert" ) diff --git a/providers/steam/session.go b/providers/steam/session.go index 2adb91b54..69237c5ff 100644 --- a/providers/steam/session.go +++ b/providers/steam/session.go @@ -4,7 +4,7 @@ package steam import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "io/ioutil" "net/http" "net/url" diff --git a/providers/steam/session_test.go b/providers/steam/session_test.go index 5bc2be9f9..f96dd8cab 100644 --- a/providers/steam/session_test.go +++ b/providers/steam/session_test.go @@ -1,8 +1,8 @@ package steam_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/steam" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/steam" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/steam/steam.go b/providers/steam/steam.go index a381b863b..2eec27158 100644 --- a/providers/steam/steam.go +++ b/providers/steam/steam.go @@ -4,7 +4,7 @@ package steam import ( "encoding/json" "fmt" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/steam/steam_test.go b/providers/steam/steam_test.go index a59a0c7df..abe902332 100644 --- a/providers/steam/steam_test.go +++ b/providers/steam/steam_test.go @@ -1,8 +1,8 @@ package steam_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/steam" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/steam" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/stripe/session.go b/providers/stripe/session.go index ebeba9f9c..c28d773b7 100644 --- a/providers/stripe/session.go +++ b/providers/stripe/session.go @@ -3,7 +3,7 @@ package stripe import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/stripe/session_test.go b/providers/stripe/session_test.go index ac40f2d9b..9aab52a49 100644 --- a/providers/stripe/session_test.go +++ b/providers/stripe/session_test.go @@ -1,8 +1,8 @@ package stripe_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/stripe" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/stripe" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/stripe/stripe.go b/providers/stripe/stripe.go index 5757319ad..3917491cb 100644 --- a/providers/stripe/stripe.go +++ b/providers/stripe/stripe.go @@ -4,7 +4,7 @@ package stripe import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/stripe/stripe_test.go b/providers/stripe/stripe_test.go index ed087f5c8..2240c4508 100644 --- a/providers/stripe/stripe_test.go +++ b/providers/stripe/stripe_test.go @@ -1,8 +1,8 @@ package stripe_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/stripe" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/stripe" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/twitch/session.go b/providers/twitch/session.go index d7f27b580..674603e49 100644 --- a/providers/twitch/session.go +++ b/providers/twitch/session.go @@ -3,7 +3,7 @@ package twitch import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/twitch/session_test.go b/providers/twitch/session_test.go index d616416c1..309a9d7fe 100644 --- a/providers/twitch/session_test.go +++ b/providers/twitch/session_test.go @@ -3,7 +3,7 @@ package twitch import ( "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/twitch/twitch.go b/providers/twitch/twitch.go index f58e217ec..6dfc2143f 100644 --- a/providers/twitch/twitch.go +++ b/providers/twitch/twitch.go @@ -4,7 +4,7 @@ package twitch import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/twitch/twitch_test.go b/providers/twitch/twitch_test.go index e0123f593..504ab092a 100644 --- a/providers/twitch/twitch_test.go +++ b/providers/twitch/twitch_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/markbates/goth" + "github.com/jtolds/goth" "github.com/stretchr/testify/assert" ) diff --git a/providers/twitter/session.go b/providers/twitter/session.go index 8c205eed2..8aac2aefa 100644 --- a/providers/twitter/session.go +++ b/providers/twitter/session.go @@ -3,9 +3,11 @@ package twitter import ( "encoding/json" "errors" - "github.com/markbates/goth" - "github.com/mrjones/oauth" "strings" + + "github.com/jtolds/goth" + "github.com/jtolds/oauth" + "golang.org/x/net/context" ) // Session stores data during the auth process with Twitter. @@ -23,10 +25,15 @@ func (s Session) GetAuthURL() (string, error) { return s.AuthURL, nil } -// Authorize the session with Twitter and return the access token to be stored for future use. func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { + return s.AuthorizeCtx(context.TODO(), provider, params) +} + +// AuthorizeCtx the session with Twitter and return the access token to be stored for future use. +func (s *Session) AuthorizeCtx(ctx context.Context, provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) - accessToken, err := p.consumer.AuthorizeToken(s.RequestToken, params.Get("oauth_verifier")) + accessToken, err := p.consumer.AuthorizeTokenWithParamsCtx( + ctx, s.RequestToken, params.Get("oauth_verifier"), p.consumer.AdditionalParams) if err != nil { return "", err } diff --git a/providers/twitter/session_test.go b/providers/twitter/session_test.go index 1773b07b9..e26c178e6 100644 --- a/providers/twitter/session_test.go +++ b/providers/twitter/session_test.go @@ -3,8 +3,8 @@ package twitter_test import ( "testing" - "github.com/markbates/goth" - "github.com/markbates/goth/providers/twitter" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/twitter" "github.com/stretchr/testify/assert" ) diff --git a/providers/twitter/twitter.go b/providers/twitter/twitter.go index 587b32d94..ba708f448 100644 --- a/providers/twitter/twitter.go +++ b/providers/twitter/twitter.go @@ -6,10 +6,15 @@ import ( "bytes" "encoding/json" "errors" - "github.com/markbates/goth" - "github.com/mrjones/oauth" - "golang.org/x/oauth2" "io/ioutil" + "net/http" + "net/url" + + "github.com/jtolds/goth" + "github.com/jtolds/oauth" + "golang.org/x/net/context" + "golang.org/x/oauth2" + "gopkg.in/webhelp.v1/whcompat" ) var ( @@ -32,6 +37,9 @@ func New(clientKey, secret, callbackURL string) *Provider { CallbackURL: callbackURL, } p.consumer = newConsumer(p, authorizeURL) + p.consumer.HttpClientFunc = func(ctx context.Context) (oauth.HttpClient, error) { + return goth.HTTPClient(ctx) + } return p } @@ -66,10 +74,14 @@ func (p *Provider) Debug(debug bool) { p.debug = debug } -// BeginAuth asks Twitter for an authentication end-point and a request token for a session. -// Twitter does not support the "state" variable. func (p *Provider) BeginAuth(state string) (goth.Session, error) { - requestToken, url, err := p.consumer.GetRequestTokenAndUrl(p.CallbackURL) + return p.BeginAuthCtx(context.TODO(), state) +} + +// BeginAuthCtx asks Twitter for an authentication end-point and a request token for a session. +// Twitter does not support the "state" variable. +func (p *Provider) BeginAuthCtx(ctx context.Context, state string) (goth.Session, error) { + requestToken, url, err := p.consumer.GetRequestTokenAndUrlWithParamsCtx(ctx, p.CallbackURL, p.consumer.AdditionalParams) session := &Session{ AuthURL: url, RequestToken: requestToken, @@ -77,17 +89,31 @@ func (p *Provider) BeginAuth(state string) (goth.Session, error) { return session, err } -// FetchUser will go to Twitter and access basic information about the user. func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { + return p.FetchUserCtx(context.TODO(), session) +} + +// FetchUserCtx will go to Twitter and access basic information about the user. +func (p *Provider) FetchUserCtx(ctx context.Context, session goth.Session) (goth.User, error) { user := goth.User{ Provider: p.Name(), } sess := session.(*Session) - response, err := p.consumer.Get( - endpointProfile, - map[string]string{"include_entities": "false", "skip_status": "true"}, - sess.AccessToken) + + client, err := p.consumer.MakeHttpClient(sess.AccessToken) + if err != nil { + return user, err + } + + req, err := http.NewRequest("GET", endpointProfile+"?"+(url.Values{ + "include_entities": []string{"false"}, + "skip_status": []string{"true"}}).Encode(), nil) + if err != nil { + return user, err + } + req = whcompat.WithContext(req, ctx) + response, err := client.Do(req) if err != nil { return user, err } @@ -124,8 +150,13 @@ func newConsumer(provider *Provider, authURL string) *oauth.Consumer { return c } -//RefreshToken refresh token is not provided by twitter func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) { + return p.RefreshTokenCtx(context.TODO(), refreshToken) +} + +// RefreshTokenCtx refresh token is not provided by twitter +func (p *Provider) RefreshTokenCtx(ctx context.Context, refreshToken string) ( + *oauth2.Token, error) { return nil, errors.New("Refresh token is not provided by twitter") } diff --git a/providers/twitter/twitter_test.go b/providers/twitter/twitter_test.go index 9763a1e30..8077e3655 100644 --- a/providers/twitter/twitter_test.go +++ b/providers/twitter/twitter_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/gorilla/pat" - "github.com/markbates/goth" - "github.com/mrjones/oauth" + "github.com/jtolds/goth" + "github.com/jtolds/oauth" "github.com/stretchr/testify/assert" ) diff --git a/providers/uber/session.go b/providers/uber/session.go index bdad34068..5b0f8919d 100644 --- a/providers/uber/session.go +++ b/providers/uber/session.go @@ -3,7 +3,7 @@ package uber import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/uber/session_test.go b/providers/uber/session_test.go index 86b4c3aec..b18fa6ef1 100644 --- a/providers/uber/session_test.go +++ b/providers/uber/session_test.go @@ -1,8 +1,8 @@ package uber_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/uber" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/uber" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/uber/uber.go b/providers/uber/uber.go index a055cd1ea..6fddbaa26 100644 --- a/providers/uber/uber.go +++ b/providers/uber/uber.go @@ -4,7 +4,7 @@ package uber import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/uber/uber_test.go b/providers/uber/uber_test.go index f6bf954d7..33a54f5ab 100644 --- a/providers/uber/uber_test.go +++ b/providers/uber/uber_test.go @@ -1,8 +1,8 @@ package uber_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/uber" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/uber" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/wepay/session.go b/providers/wepay/session.go index 11b08e16c..c16fc1946 100644 --- a/providers/wepay/session.go +++ b/providers/wepay/session.go @@ -3,7 +3,7 @@ package wepay import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/wepay/session_test.go b/providers/wepay/session_test.go index 4891e8848..6c7d44990 100644 --- a/providers/wepay/session_test.go +++ b/providers/wepay/session_test.go @@ -1,8 +1,8 @@ package wepay_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/wepay" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/wepay" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/wepay/wepay.go b/providers/wepay/wepay.go index 620764ceb..107e8a380 100644 --- a/providers/wepay/wepay.go +++ b/providers/wepay/wepay.go @@ -4,7 +4,7 @@ package wepay import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/wepay/wepay_test.go b/providers/wepay/wepay_test.go index 831e14c3f..abbcaa8b6 100644 --- a/providers/wepay/wepay_test.go +++ b/providers/wepay/wepay_test.go @@ -1,8 +1,8 @@ package wepay_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/wepay" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/wepay" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/yahoo/session.go b/providers/yahoo/session.go index daba13e83..79f3f43ed 100644 --- a/providers/yahoo/session.go +++ b/providers/yahoo/session.go @@ -3,7 +3,7 @@ package yahoo import ( "encoding/json" "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strings" "time" diff --git a/providers/yahoo/session_test.go b/providers/yahoo/session_test.go index c0352e04f..3d5975f2f 100644 --- a/providers/yahoo/session_test.go +++ b/providers/yahoo/session_test.go @@ -1,8 +1,8 @@ package yahoo_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/yahoo" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/yahoo" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/yahoo/yahoo.go b/providers/yahoo/yahoo.go index c3c65207d..2b3e0e78a 100644 --- a/providers/yahoo/yahoo.go +++ b/providers/yahoo/yahoo.go @@ -4,7 +4,7 @@ package yahoo import ( "encoding/json" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "io" "net/http" diff --git a/providers/yahoo/yahoo_test.go b/providers/yahoo/yahoo_test.go index 97506cb6a..44cc0d9fe 100644 --- a/providers/yahoo/yahoo_test.go +++ b/providers/yahoo/yahoo_test.go @@ -1,8 +1,8 @@ package yahoo_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/yahoo" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/yahoo" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/providers/yammer/session.go b/providers/yammer/session.go index db2cf3012..df646106c 100644 --- a/providers/yammer/session.go +++ b/providers/yammer/session.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "github.com/markbates/goth" + "github.com/jtolds/goth" "io" "io/ioutil" "net/http" diff --git a/providers/yammer/session_test.go b/providers/yammer/session_test.go index c400d21e4..af20d1f92 100644 --- a/providers/yammer/session_test.go +++ b/providers/yammer/session_test.go @@ -1,8 +1,8 @@ package yammer_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/yammer" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/yammer" "github.com/stretchr/testify/assert" "testing" ) diff --git a/providers/yammer/yammer.go b/providers/yammer/yammer.go index 6c91c6f46..de96df6f7 100644 --- a/providers/yammer/yammer.go +++ b/providers/yammer/yammer.go @@ -4,7 +4,7 @@ package yammer import ( "errors" - "github.com/markbates/goth" + "github.com/jtolds/goth" "golang.org/x/oauth2" "strconv" ) diff --git a/providers/yammer/yammer_test.go b/providers/yammer/yammer_test.go index aa048991d..8d1f10cc9 100644 --- a/providers/yammer/yammer_test.go +++ b/providers/yammer/yammer_test.go @@ -1,8 +1,8 @@ package yammer_test import ( - "github.com/markbates/goth" - "github.com/markbates/goth/providers/yammer" + "github.com/jtolds/goth" + "github.com/jtolds/goth/providers/yammer" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/session.go b/session.go index 2d40b50bb..9fa80fc96 100644 --- a/session.go +++ b/session.go @@ -1,5 +1,9 @@ package goth +import ( + "golang.org/x/net/context" +) + // Params is used to pass data to sessions for authorization. An existing // implementation, and the one most likely to be used, is `url.Values`. type Params interface { @@ -11,11 +15,18 @@ type Params interface { // the start and the end of the authorization process with a // 3rd party provider. type Session interface { - // GetAuthURL returns the URL for the authentication end-point for the provider. + // GetAuthURL returns the URL for the authentication end-point for the + // provider. Implementations should not make outbound HTTP requests. GetAuthURL() (string, error) - // Marshal generates a string representation of the Session for storing between requests. + // Marshal generates a string representation of the Session for storing + // between requests. Implementations should not make outbound HTTP requests. Marshal() string - // Authorize should validate the data from the provider and return an access token - // that can be stored for later access to the provider. + + // This method is deprecated. Please see AuthorizeCtx. Authorize(Provider, Params) (string, error) + + // This method is now preferred. + // Authorize should validate the data from the provider and return an access + // token that can be stored for later access to the provider. + AuthorizeCtx(context.Context, Provider, Params) (string, error) }