StoreToken stores a token in the cache or updates the existing token element
(token *oauth2.Token)
| 106 | |
| 107 | // StoreToken stores a token in the cache or updates the existing token element |
| 108 | func (c *Cache) StoreToken(token *oauth2.Token) error { |
| 109 | Log.Debugf("Storing token to cache") |
| 110 | |
| 111 | tokenJSON, err := json.Marshal(token) |
| 112 | if nil != err { |
| 113 | Log.Debugf("%v", err) |
| 114 | return fmt.Errorf("Could not generate token.json content") |
| 115 | } |
| 116 | |
| 117 | if err := ioutil.WriteFile(c.tokenPath, tokenJSON, 0644); nil != err { |
| 118 | Log.Debugf("%v", err) |
| 119 | return fmt.Errorf("Could not generate token.json file") |
| 120 | } |
| 121 | |
| 122 | return nil |
| 123 | } |
| 124 | |
| 125 | // GetObject gets an object by id |
| 126 | func (c *Cache) GetObject(id string) (object *APIObject, err error) { |