GetCode obtains a new device code. Additional scopes beyond openid and email can be sent by passing in arguments for .
(audience string, additionalScopes ...string)
| 70 | // beyond openid and email can be sent by passing in arguments for |
| 71 | // <additionalScopes>. |
| 72 | func (cp *LocalDeviceCodeProvider) GetCode(audience string, additionalScopes ...string) (*DeviceCodeResult, error) { |
| 73 | request, err := cp.newDeviceCodeRequest(&DeviceCodeRequest{ |
| 74 | ClientID: cp.options.ClientID, |
| 75 | Scopes: append([]string{"openid", "email"}, additionalScopes...), |
| 76 | Audience: audience, |
| 77 | }) |
| 78 | if err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | |
| 82 | response, err := cp.transport.Do(request) |
| 83 | if err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | |
| 87 | dcr, err := cp.handleDeviceCodeResponse(response) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | |
| 92 | return dcr, nil |
| 93 | } |
| 94 | |
| 95 | // newDeviceCodeRequest builds a new DeviceCodeRequest wrapped in an |
| 96 | // http.Request |
nothing calls this directly
no test coverage detected