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.

Revisions

  1. ImDevinC created this gist Sep 24, 2023.
    35 changes: 35 additions & 0 deletions main.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    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))
    }