LoadToken loads a token from cache
()
| 88 | |
| 89 | // LoadToken loads a token from cache |
| 90 | func (c *Cache) LoadToken() (*oauth2.Token, error) { |
| 91 | Log.Debugf("Loading token from cache") |
| 92 | |
| 93 | tokenFile, err := ioutil.ReadFile(c.tokenPath) |
| 94 | if nil != err { |
| 95 | Log.Debugf("%v", err) |
| 96 | return nil, fmt.Errorf("Could not read token file in %v", c.tokenPath) |
| 97 | } |
| 98 | |
| 99 | var token oauth2.Token |
| 100 | json.Unmarshal(tokenFile, &token) |
| 101 | |
| 102 | Log.Tracef("Got token from cache %v", token) |
| 103 | |
| 104 | return &token, nil |
| 105 | } |
| 106 | |
| 107 | // StoreToken stores a token in the cache or updates the existing token element |
| 108 | func (c *Cache) StoreToken(token *oauth2.Token) error { |