Skip to content

Instantly share code, notes, and snippets.

@pmenglund
Created December 14, 2022 03:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pmenglund/b2ac7bb15ce25755a69573f5a063cb14 to your computer and use it in GitHub Desktop.
OAuth Device Flow part two
url := "https://internal.rockset.com/api/"
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)
}
fmt.Println(string(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment