()
| 145 | } |
| 146 | |
| 147 | func generateNonce() (string, error) { |
| 148 | b := make([]byte, 32) |
| 149 | if _, err := rand.Read(b); err != nil { |
| 150 | return "", err |
| 151 | } |
| 152 | return base64.RawURLEncoding.EncodeToString(b), nil |
| 153 | } |
| 154 | |
| 155 | // Exchange exchanges the authorization code for tokens and fetches UserInfo. |
| 156 | func (c *Client) Exchange(ctx context.Context, code, codeVerifier, expectedState, expectedNonce string, callbackParams url.Values) (*UserInfo, error) { |