Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2022 03:37
What would you like to do?
OAuth Device Flow part two
url := ""
body := bytes.NewBufferString(`{"request":"foobar"}`)
request, err := http.NewRequestWithContext(ctx, http.MethodPost, url, body)
if err != nil {
log.Fatalf("failed to create request %v", err)
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken))
response, err := http.DefaultClient.Do(request)
if err != nil {
log.Fatalf("failed to make the HTTP request %v", err)
defer func() {
if err := response.Body.Close(); err != nil {
log.Printf("failed to close body: %v", err)
data, err := io.ReadAll(response.Body)
if err != nil {
log.Fatalf("failed to read response body %v", err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment