https://github.com/dakimura/oauth2-token-chain
https://github.com/dakimura/oauth2-token-chain
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dakimura/oauth2-token-chain
- Owner: dakimura
- License: mit
- Created: 2020-07-27T01:29:33.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T01:44:19.000Z (almost 5 years ago)
- Last Synced: 2023-03-11T04:03:30.242Z (about 2 years ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Oauth2 Token Source Chain
oauth2-token-chain package contains an implementation to have multiple `oauth2.TokenSource`s
## Installation
~~~~
go get "github.com/dakimura/oauth2-token-chain/oauth2"
~~~~Or you can manually git clone the repository to
`$(go env GOPATH)/src/github.com/dakimura/oauth2-token-chain`.## Usage
inject some token sources for testing, caching or for some other reasons
```
package exampleimport (
"github.com/dakimura/oauth2-token-chain/oauth2"
googleoauth2 "golang.org/x/oauth2"
)
func main(){
chainedTokenSource := oauth2.NewChainedTokenSource(
&CachedSomeTokenSource{},
&SomeTokenSource{},
googleoauth2.StaticTokenSource(&googleoauth2.Token{AccessToken: "e.g. staticAccesstokenForTest"}),
)// try to get token from each token source in order.
token, err := chainedTokenSource.Token()
if err != nil {
print(err)
}
print(token)
}
```