git.iko.soy/typeable/oauth2-proxy
on master help sign in
print full error message when non-api error (#474)

when type asserting fails here, err is reassigned with nil and the default block of the switch prints out <nil> in the error message. This makes debugging a configuration or access token issue difficult The particular error this surfaces is: Response: { "error": "unauthorized_client", "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested." } Signed-off-by: Josh Bielick <jbielick@gmail.com>

commitf9f98cb3a7511ade5bb3203d2b022e2747bc5434 authorJosh Bielick <jbielick@users.noreply.github.com> dateMon 6 Apr 2020, 04:27 (7 years ago) parentc7bfbde
2 files changed+4−3
CHANGELOG.md+1 providers/google.go+3−3
CHANGELOG.md+1
@@ -12,6 +12,7 @@
1212
1313## Changes since v5.1.0
1414
15+- [#474](https://github.com/oauth2-proxy/oauth2-proxy/pull/474) Always log hasMember request error object (@jbielick)
1516- [#468](https://github.com/oauth2-proxy/oauth2-proxy/pull/468) Implement graceful shutdown and propagate request context (@johejo)
1617- [#464](https://github.com/oauth2-proxy/oauth2-proxy/pull/464) Migrate to oauth2-proxy/oauth2-proxy (@JoelSpeed)
1718 - Project renamed from `pusher/oauth2_proxy` to `oauth2-proxy`
providers/google.go+3−3
@@ -198,11 +198,11 @@ func userInGroup(service *admin.Service, groups []string, email string) bool {
198198 req := service.Members.HasMember(group, email)
199199 r, err := req.Do()
200200 if err != nil {
201− err, ok := err.(*googleapi.Error)
201+ gerr, ok := err.(*googleapi.Error)
202202 switch {
203− case ok && err.Code == 404:
203+ case ok && gerr.Code == 404:
204204 logger.Printf("error checking membership in group %s: group does not exist", group)
205− case ok && err.Code == 400:
205+ case ok && gerr.Code == 400:
206206 // It is possible for Members.HasMember to return false even if the email is a group member.
207207 // One case that can cause this is if the user email is from a different domain than the group,
208208 // e.g. "member@otherdomain.com" in the group "group@mydomain.com" will result in a 400 error