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

Function SaveToken

auth.go:77–86  ·  view source on GitHub ↗

SaveToken will serialize the provided token and save it to the file whose path is defined in the diskplayer. yaml configuration file under the token.file_path field. Returns an error if one is encountered.

(token *oauth2.Token)

Source from the content-addressed store, hash-verified

75// configuration file under the token.file_path field.
76// Returns an error if one is encountered.
77func SaveToken(token *oauth2.Token) error {
78 p := ConfigValue(TOKEN_PATH)
79
80 f, err := os.OpenFile(p, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
81 if err != nil {
82 return err
83 }
84 defer f.Close()
85 return json.NewEncoder(f).Encode(token)
86}

Callers 3

mainFunction · 0.92
TestSaveTokenFunction · 0.85
TestSaveTokenWriteErrorFunction · 0.85

Calls 1

ConfigValueFunction · 0.85

Tested by 2

TestSaveTokenFunction · 0.68
TestSaveTokenWriteErrorFunction · 0.68