What this change means
Source files changed in ways the catalog does not model (for example logic inside Verify). Read the diff to judge the effect.
| @@ -128,9 +128,10 @@ func verifyRefreshToken(ctx context.Context, client *http.Client, token string) | ||
| 128 | 128 | // If the token is invalid, it returns false and no error. |
| 129 | 129 | // If an error is encountered, it returns false along with the error. |
| 130 | 130 | func verifyAccessToken(ctx context.Context, client *http.Client, token string) (bool, error) { |
| 131 | removed: // Ref: https://docs.digitalocean.com/reference/api/digitalocean/#tag/Account | |
| 131 | added: // Use the same token validation endpoint as doctl for API tokens and model access keys. | |
| 132 | added: // Ref: https://github.com/digitalocean/doctl/blob/main/do/oauth.go | |
| 132 | 133 | |
| 133 | removed: url := "https://api.digitalocean.com/v2/account" | |
| 134 | added: url := "https://cloud.digitalocean.com/v1/oauth/token/info" | |
| 134 | 135 | req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) |
| 135 | 136 | if err != nil { |
| 136 | 137 | return false, fmt.Errorf("failed to create request: %w", err) |
| @@ -146,7 +147,8 @@ func verifyAccessToken(ctx context.Context, client *http.Client, token string) ( | ||
| 146 | 147 | switch res.StatusCode { |
| 147 | 148 | case http.StatusOK: |
| 148 | 149 | return true, nil |
| 149 | removed: case http.StatusUnauthorized: | |
| 150 | added: case http.StatusBadRequest, http.StatusUnauthorized: | |
| 151 | added: // The token-info endpoint can reject invalid tokens with either status. | |
| 150 | 152 | return false, nil |
| 151 | 153 | default: |
| 152 | 154 | return false, fmt.Errorf("unexpected status code: %d", res.StatusCode) |