Skip to content

Commit 61087c7

Browse files
committed
Adds more cleanup from writing the post
Both of these edits should make it a bit easier to follow in the blog post
1 parent f2181c3 commit 61087c7

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

cmd/login.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const (
2323

2424
// TenantID is the ID of our FA instance's default Tenant
2525
TenantID string = "8caf6467-fb94-6b02-e19c-46536e8e62ad"
26-
27-
grantType string = "urn:ietf:params:oauth:grant-type:device_code"
2826
)
2927

3028
var (
@@ -104,7 +102,11 @@ func startPolling(tokenEndpoint string, deviceCode string, retryInterval int) (*
104102
blue := color.New(color.FgBlue, color.Bold)
105103

106104
for {
107-
resp, err := pollRequest(tokenEndpoint, deviceCode)
105+
resp, err := http.PostForm(tokenEndpoint, url.Values{
106+
"device_code": {deviceCode},
107+
"grant_type": {"urn:ietf:params:oauth:grant-type:device_code"},
108+
"client_id": {ClientID},
109+
})
108110

109111
if err != nil {
110112
return result, err
@@ -135,17 +137,6 @@ func startPolling(tokenEndpoint string, deviceCode string, retryInterval int) (*
135137
}
136138
}
137139

138-
func pollRequest(tokenEndpoint string, deviceCode string) (*http.Response, error) {
139-
requestBody := url.Values{
140-
"device_code": {deviceCode},
141-
"grant_type": {grantType},
142-
"client_id": {ClientID},
143-
}
144-
resp, err := http.PostForm(tokenEndpoint, requestBody)
145-
146-
return resp, err
147-
}
148-
149140
func fetchAndSaveUser(token *fusionauth.AccessToken) {
150141
resp, _, err := faClient.RetrieveUserUsingJWT(token.AccessToken)
151142
if err != nil {

0 commit comments

Comments
 (0)