Open rakyll opened 10 years ago
+1
Or at least some sort of hook we could use once the oauth handshake is completed so that we could do this ourselves...?
I added this (probably somewhat ugly) hack to test this functionality and worked fine with Google atleast.
type Requests interface {
Get(url string) []byte
}
type request struct {
token
}
func (r *request) Get(url string) []byte {
transport := &oauth.Transport{}
transport.Token = &oauth.Token{r.AccessToken, r.RefreshToken, r.Expiry, r.Extra}
resp, _ := transport.Client().Get(url)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
return body
}
resp := request.Get("https://www.googleapis.com/plus/v1/people/me")
json.Unmarshal(resp, &profile)
in my function (with request oauth2.Requests
via the injector)
Any comments on this method? Just returning the http.Client() would probably be better so people could easily add headers and POST, PUT, DELETE and whatever they might need. This was just a quick hack to test the idea.
Authentication (who is the user) and authorisation (what am I allowed to do, which is the scope of the OAuth 2.0 standard) are pretty different things.
There isn't really anything called a OAuth2 profile and the data model of the profile on each different API (and scope) is pretty different.
Maybe it would help if we could define what was meant with a profile getter? What exact information from each service is it meant to retrieve? Simpe userID stuff or something a bit more complete? A full-fledged profile getter might be better served as a separate handler that depends on this one.
This shouldn't be in OAuth2 library logic.
What is a "profile getter" ?