-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[provider/google] Always log hasMember request error object #474
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
Conversation
for _, group := range groups { | ||
// Use the HasMember API to checking for the user's presence in each group or nested subgroups | ||
req := service.Members.HasMember(group, email) | ||
r, err := req.Do() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err
here is what I want to print.
r, err := req.Do() | ||
if err != nil { | ||
err, ok := err.(*googleapi.Error) | ||
gerr, ok := err.(*googleapi.Error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reassignment of err
here writes nil
to err
when the type assertion fails. I don't know what type err
is before this. The error object is:
oauth2: cannot fetch token: 401 Unauthorized
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."
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense! Please add an entry to the changelog and we can get it merged, thanks for the fix!
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>
@JoelSpeed sure thing. Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Description
Logs the original request error for group membership check to google
Motivation and Context
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.Before:
After:
The issue seemed to be that
I needed an additional OAuth scope,The Admin SDK API was not enabled.https://www.googleapis.com/auth/admin.directory.group.member.readonly
, which I intend to add to the docs in another PR.How Has This Been Tested?
I'm currently trying to get this working with nginx-ingress-controller. I cloned this repo, made the change, ran the tests, built the image, pushed it, and used my custom image and got the error message in my logs.
Checklist: