For the social media login:
- Create a req variable by passing in the login API url to the http.NewRequest()
var req = http.NewRequest("GET", {url}, nil)
- Add the
Bearer {accessToken}
to the Authorization header
req.Headers.Add(("Authorization", "Bearer " + accessToken)
- Pass that req variable into the Client.Do() and store the response in the response variable
var res = Client.Do(req)
- Create a struct with an ID field to store the value returned from the response
type socialResponse struct {
ID int `json:"id"`
}
- json.NewDecoder(response.Body).Decode(&socialResponse) to pass the json data into our struct
Top comments (0)