MCPcopy Create free account
hub / github.com/apache/pulsar-client-go / GetCode

Method GetCode

oauth2/device_code_provider.go:72–93  ·  view source on GitHub ↗

GetCode obtains a new device code. Additional scopes beyond openid and email can be sent by passing in arguments for .

(audience string, additionalScopes ...string)

Source from the content-addressed store, hash-verified

70// beyond openid and email can be sent by passing in arguments for
71// <additionalScopes>.
72func (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

Callers

nothing calls this directly

Calls 3

newDeviceCodeRequestMethod · 0.95
DoMethod · 0.65

Tested by

no test coverage detected