Skip to content

Instantly share code, notes, and snippets.

@ImDevinC
Created September 24, 2023 21:15
Show Gist options
  • Save ImDevinC/96bd253bb7f39bee79dded5edc627e16 to your computer and use it in GitHub Desktop.
Save ImDevinC/96bd253bb7f39bee79dded5edc627e16 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
_ "github.com/joho/godotenv/autoload"
)
const pd3Url string = "https://nebula.starbreeze.com/challenge/v1/public/namespaces/pd3/users/me/records"
var token = os.Getenv("NEBULA_BEARER_TOKEN")
func main() {
if token == "" {
log.Fatal("Missing NEBULA_BEARER_TOKEN")
}
req, err := http.NewRequest(http.MethodGet, pd3Url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
body, err := io.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
log.Println(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment