ReadToken will attempt to deserialize a token whose path is defined in the diskplayer.yaml configuration file under the token.file_path field. Returns a pointer to an oauth2 token object or any error encountered.
()
| 59 | // configuration file under the token.file_path field. |
| 60 | // Returns a pointer to an oauth2 token object or any error encountered. |
| 61 | func ReadToken() (*oauth2.Token, error) { |
| 62 | p := ConfigValue(TOKEN_PATH) |
| 63 | |
| 64 | f, err := os.Open(p) |
| 65 | if err != nil { |
| 66 | return nil, err |
| 67 | } |
| 68 | defer f.Close() |
| 69 | t := &oauth2.Token{} |
| 70 | err = json.NewDecoder(f).Decode(t) |
| 71 | return t, err |
| 72 | } |
| 73 | |
| 74 | // SaveToken will serialize the provided token and save it to the file whose path is defined in the diskplayer. yaml |
| 75 | // configuration file under the token.file_path field. |