func (u *UserInfo) Get(token oauth2.Token) { ns := napping.Session{} ns.Header = &http.Header{} ns.Header.Add("Authorization", "Bearer "+token.AccessToken) url := settings.UnifiedApiEndpointUrl + "/me" resp, err := ns.Get(url, nil, &u, nil) if err != nil { log.Fatal(err) } if resp.Status() == 200 { fmt.Println("Loaded profile for :", u.Displayname) } else { fmt.Println("Bad response status from office365 unified api") fmt.Println("Raw Response Text : %s", resp.RawText()) } }
func Get(url string, token oauth2.Token) string { ns := napping.Session{} ns.Header = &http.Header{} ns.Header.Add("Authorization", "Bearer "+token.AccessToken) resp, err := ns.Get(url, nil, nil, nil) if err != nil { log.Fatal(err) } fmt.Println("Status : %i", resp.Status()) fmt.Println("Server response %s", resp.RawText()) dst := new(bytes.Buffer) src := []byte(resp.RawText()) json.Indent(dst, src, "", "\t") return dst.String() }