MCPcopy Create free account
hub / github.com/dinofizz/diskplayer / ReadToken

Function ReadToken

auth.go:61–72  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

59// configuration file under the token.file_path field.
60// Returns a pointer to an oauth2 token object or any error encountered.
61func 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.

Callers 3

mainFunction · 0.92
TestReadTokenFunction · 0.85
TestReadTokenFileErrorFunction · 0.85

Calls 1

ConfigValueFunction · 0.85

Tested by 2

TestReadTokenFunction · 0.68
TestReadTokenFileErrorFunction · 0.68