forked from dghubble/oauth1
-
Notifications
You must be signed in to change notification settings - Fork 2
/
token.go
36 lines (30 loc) · 937 Bytes
/
token.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package oauth1
// A TokenSource can return a Token.
type TokenSource interface {
Token() (*Token, error)
}
// Token is an AccessToken (token credential) which allows a consumer (client)
// to access resources from an OAuth1 provider server.
type Token struct {
Token string
TokenSecret string
}
// NewToken returns a new Token with the given token and token secret.
func NewToken(token, tokenSecret string) *Token {
return &Token{
Token: token,
TokenSecret: tokenSecret,
}
}
// StaticTokenSource returns a TokenSource which always returns the same Token.
// This is appropriate for tokens which do not have a time expiration.
func StaticTokenSource(token *Token) TokenSource {
return staticTokenSource{token}
}
// staticTokenSource is a TokenSource that always returns the same Token.
type staticTokenSource struct {
token *Token
}
func (s staticTokenSource) Token() (*Token, error) {
return s.token, nil
}