Last active
March 14, 2018 09:21
-
-
Save chrisvdg/2cecdf02d02aa6673313a206cb33e191 to your computer and use it in GitHub Desktop.
Get IYO JWT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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