Skip to content

Instantly share code, notes, and snippets.

@chrisvdg
Last active March 14, 2018 09:21
Show Gist options
  • Save chrisvdg/2cecdf02d02aa6673313a206cb33e191 to your computer and use it in GitHub Desktop.
Save chrisvdg/2cecdf02d02aa6673313a206cb33e191 to your computer and use it in GitHub Desktop.
Get IYO JWT
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest("POST", "https://itsyou.online/v1/oauth/access_token", nil)
if err != nil {
log.Print(err)
os.Exit(1)
}
q := req.URL.Query()
q.Add("grant_type", "client_credentials")
q.Add("response_type", "id_token")
q.Add("client_id", os.Getenv("CLIENT_ID"))
q.Add("client_secret", os.Getenv("CLIENT_SECRET"))
q.Add("validity", "86400")
q.Add("scope", "user:memberof:testorg")
req.URL.RawQuery = q.Encode()
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Errored when sending request to the server")
return
}
defer resp.Body.Close()
respBody, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(respBody))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment