loadLoginRequestedScope loads the cached requested scope string for a device_code. It returns an empty string if no cache entry exists.
(deviceCode string)
| 57 | // loadLoginRequestedScope loads the cached requested scope string for a device_code. |
| 58 | // It returns an empty string if no cache entry exists. |
| 59 | func loadLoginRequestedScope(deviceCode string) (string, error) { |
| 60 | data, err := vfs.ReadFile(loginScopeCachePath(deviceCode)) |
| 61 | if err != nil { |
| 62 | if errors.Is(err, os.ErrNotExist) { |
| 63 | return "", nil |
| 64 | } |
| 65 | return "", err |
| 66 | } |
| 67 | var record loginScopeCacheRecord |
| 68 | if err := json.Unmarshal(data, &record); err != nil { |
| 69 | _ = vfs.Remove(loginScopeCachePath(deviceCode)) |
| 70 | return "", err |
| 71 | } |
| 72 | return record.RequestedScope, nil |
| 73 | } |
| 74 | |
| 75 | // removeLoginRequestedScope deletes the cache entry for a device_code. |
| 76 | func removeLoginRequestedScope(deviceCode string) error { |