-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
userinfo: expose http response information to library callers #248
Comments
Is this to figure out when you need to rotate the token? There's a lot of customization that request could use, and I don't know if we want to start going down the path of exposing knobs. Maybe make it easier to make the request yourself? e.g. we could export the user info URL to the Provider struct: type Provider struct {
UserInfoURL string
} As well as have func (u *UserInfo) UnmarshalJSON(b []byte) error Then you could customize your error handling: req, err := http.NewRequest("GET", p.UserInfo, nil)
if err != nil {
// ...
}
token.SetAuthHeader(req)
resp, err := myClient.Do(req)
if err != nil {
// ...
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
// your custom error handling
}
var u oidc.UserInfo
if err := json.NewDecoder(resp.Body).Decode(&u); err != nil {
// ...
} I'd like to avoid dealing with OAuth2 semantics as much as possible 😄 that's what golang.org/x/oauth2 is for. |
I just bumped into this. I wanted to use |
@ericchiang thanks for taking the time such a detailed reply. |
The current
UserInfo()
function makes an HTTP request and if something goes wrong, it returns a string error:go-oidc/oidc.go
Lines 229 to 231 in 8d77155
I need to check the return code of the request to find out more about the reason it was denied (if the request was unauthorized, an internal error occurred at the server, etc.).
See also: https://www.rfc-editor.org/rfc/rfc6750.html#section-3.1
Would it be reasonable to define an error type for this kind of information?
The oauth2 package uses a
RetrieveError
for these cases:cc @ericchiang
The text was updated successfully, but these errors were encountered: