MCPcopy Create free account
hub / github.com/algolia/cli / LoadToken

Function LoadToken

pkg/auth/token_store.go:77–93  ·  view source on GitHub ↗

LoadToken reads the stored token from the OS keychain. Returns nil if not found.

()

Source from the content-addressed store, hash-verified

75
76// LoadToken reads the stored token from the OS keychain. Returns nil if not found.
77func LoadToken() *StoredToken {
78 secret, err := keyring.Get(keyringService, keyringUser)
79 if err != nil {
80 return nil
81 }
82
83 var stored StoredToken
84 if err := json.Unmarshal([]byte(secret), &stored); err != nil {
85 return nil
86 }
87
88 if stored.AccessToken == "" {
89 return nil
90 }
91
92 return &stored
93}
94
95// ClearToken removes the stored token from the OS keychain.
96func ClearToken() {

Calls 1

GetMethod · 0.80