Update to oauth2 example.

This commit is contained in:
Phillip Baker 2015-05-18 23:45:02 -04:00
parent 8eb611fd0c
commit 80e737c091
1 changed files with 15 additions and 4 deletions

View File

@ -27,14 +27,25 @@ at the Digital Ocean Control Panel [Applications Page](https://cloud.digitalocea
You can then use your token to create a new client:
```go
import "code.google.com/p/goauth2/oauth"
import "golang.org/x/oauth2"
pat := "mytoken"
t := &oauth.Transport{
Token: &oauth.Token{AccessToken: pat},
type TokenSource struct {
AccessToken string
}
client := godo.NewClient(t.Client())
func (t *TokenSource) Token() (*oauth2.Token, error) {
token := &oauth2.Token{
AccessToken: t.AccessToken,
}
return token, nil
}
tokenSource := &TokenSource{
AccessToken: pat,
}
oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
client := godo.NewClient(oauthClient)
```
## Examples