diff options
| author | Petter Rasmussen | 2016-02-21 00:53:32 +0100 | 
|---|---|---|
| committer | Petter Rasmussen | 2016-02-21 00:53:32 +0100 | 
| commit | c1960cd2b0fc82054ebe64c6ec79555b991a4ff9 (patch) | |
| tree | 4a08344a01c671596f8e345ab166d4a25607f523 /auth | |
| parent | 21cc148ec34cdb65cbbca0dfb2995beea7cbc11b (diff) | |
| download | gdrive-c1960cd2b0fc82054ebe64c6ec79555b991a4ff9.tar.bz2 | |
Add support for user-provided access token
Diffstat (limited to 'auth')
| -rw-r--r-- | auth/oauth.go | 14 | 
1 files changed, 14 insertions, 0 deletions
| 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, | 
