From c1960cd2b0fc82054ebe64c6ec79555b991a4ff9 Mon Sep 17 00:00:00 2001 From: Petter Rasmussen Date: Sun, 21 Feb 2016 00:53:32 +0100 Subject: Add support for user-provided access token --- auth/oauth.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'auth/oauth.go') diff --git a/auth/oauth.go b/auth/oauth.go index 1f2884b..965c7cc 100644 --- a/auth/oauth.go +++ b/auth/oauth.go @@ -50,6 +50,20 @@ func NewRefreshTokenClient(clientId, clientSecret, refreshToken string) *http.Cl ) } +func NewAccessTokenClient(clientId, clientSecret, accessToken string) *http.Client { + conf := getConfig(clientId, clientSecret) + + token := &oauth2.Token{ + TokenType: "Bearer", + AccessToken: accessToken, + } + + return oauth2.NewClient( + oauth2.NoContext, + conf.TokenSource(oauth2.NoContext, token), + ) +} + func getConfig(clientId, clientSecret string) *oauth2.Config { return &oauth2.Config{ ClientID: clientId, -- cgit v1.2.3