| 134 | } |
| 135 | |
| 136 | func (c *Client) ExternalAuthDeviceByID(ctx context.Context, provider string) (ExternalAuthDevice, error) { |
| 137 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/external-auth/%s/device", provider), nil) |
| 138 | if err != nil { |
| 139 | return ExternalAuthDevice{}, err |
| 140 | } |
| 141 | defer res.Body.Close() |
| 142 | if res.StatusCode != http.StatusOK { |
| 143 | return ExternalAuthDevice{}, ReadBodyAsError(res) |
| 144 | } |
| 145 | var extAuth ExternalAuthDevice |
| 146 | return extAuth, json.NewDecoder(res.Body).Decode(&extAuth) |
| 147 | } |
| 148 | |
| 149 | // ExchangeGitAuth exchanges a device code for an external auth token. |
| 150 | func (c *Client) ExternalAuthDeviceExchange(ctx context.Context, provider string, req ExternalAuthDeviceExchange) error { |