Exchange includes the client_assertion signed JWT.
(ctx context.Context, code string, opts ...oauth2.AuthCodeOption)
| 122 | |
| 123 | // Exchange includes the client_assertion signed JWT. |
| 124 | func (ja *Config) Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error) { |
| 125 | signed, err := ja.jwtToken() |
| 126 | if err != nil { |
| 127 | return nil, xerrors.Errorf("failed jwt assertion: %w", err) |
| 128 | } |
| 129 | opts = append(opts, |
| 130 | oauth2.SetAuthURLParam("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), |
| 131 | oauth2.SetAuthURLParam("client_assertion", signed), |
| 132 | ) |
| 133 | return ja.cfg.Exchange(ctx, code, opts...) |
| 134 | } |
| 135 | |
| 136 | func (ja *Config) jwtToken() (string, error) { |
| 137 | now := time.Now() |