| 68 | } |
| 69 | |
| 70 | func (c *Client) GetDeviceCode(ctx context.Context, scope string) (DeviceCodeResponse, error) { |
| 71 | type deviceCodeRequest struct { |
| 72 | Audience string `json:"audience"` |
| 73 | ClientID string `json:"client_id"` |
| 74 | Scope string `json:"scope"` |
| 75 | } |
| 76 | var res DeviceCodeResponse |
| 77 | err := c.post(ctx, "/oauth/device/code", deviceCodeRequest{ |
| 78 | Audience: c.config.Audience, |
| 79 | ClientID: c.config.ClientID, |
| 80 | Scope: scope, |
| 81 | }, &res) |
| 82 | return res, err |
| 83 | } |
| 84 | |
| 85 | func (c *Client) PollDeviceCodeTokens(ctx context.Context, dcr DeviceCodeResponse) (Tokens, error) { |
| 86 | delay := time.Duration(dcr.Interval) * time.Second |