MCPcopy Create free account
hub / github.com/auth0/auth0-cli / StoreAccessToken

Function StoreAccessToken

internal/keyring/keyring.go:64–85  ·  view source on GitHub ↗
(tenant, value string)

Source from the content-addressed store, hash-verified

62}
63
64func StoreAccessToken(tenant, value string) error {
65 // First, clear any existing chunks to prevent concatenation issues.
66 for i := 0; i < secretAccessTokenMaxChunks; i++ {
67 if err := keyring.Delete(fmt.Sprintf("%s %d", secretAccessToken, i), tenant); err != nil {
68 if !errors.Is(err, keyring.ErrNotFound) {
69 return fmt.Errorf("failed to delete access token chunk from keyring: %s", err)
70 }
71 }
72 }
73
74 // Now store the new token in chunks.
75 chunks := chunk(value, secretAccessTokenChunkSizeInBytes)
76
77 for i := 0; i < len(chunks); i++ {
78 err := keyring.Set(fmt.Sprintf("%s %d", secretAccessToken, i), tenant, chunks[i])
79 if err != nil {
80 return err
81 }
82 }
83
84 return nil
85}
86
87func GetAccessToken(tenant string) (string, error) {
88 var accessToken string

Callers 5

RunLoginAsUserFunction · 0.92
RunLoginAsMachineSecretFunction · 0.92
RunLoginAsMachineJWTFunction · 0.92
RegenerateAccessTokenMethod · 0.92
TestSecretsFunction · 0.85

Calls 3

chunkFunction · 0.85
ErrorfMethod · 0.80
DeleteMethod · 0.65

Tested by 1

TestSecretsFunction · 0.68