Skip to content
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

Use a better API to check organization membership. #57

Merged
merged 2 commits into from
Mar 25, 2021

Conversation

chrisgavin
Copy link
Collaborator

This API (https://docs.github.com/en/rest/reference/orgs#check-organization-membership-for-a-user) better handles edge cases like the user having a pending invitation or not having granted the org scopes.

@simon-engledew
Copy link
Contributor

simon-engledew commented Mar 2, 2021

I just tried this branch against a recent bp-dev machine and it doesn't seem to work for me! 🤔 I get:

INFO[0000] Starting CodeQL Action sync tool version development... 
WARN[0000] https://simon-engledew-3c263321b.service.bpdev-us-east-1.github.net/api/v3 redirected to https://simon-engledew-3c263321b.service.bpdev-us-east-1.github.net/api/v3. The URL https://simon-engledew-3c263321b.service.bpdev-us-east-1.github.net/api/v3/ will be used for all API requests. 
DEBU[0000] Ensuring repository exists...                
DEBU[0001] No access to destination organization. Switching to impersonation token for actions-admin... 
FATA[0001] POST https://simon-engledew-3c263321b.service.bpdev-us-east-1.github.net/api/v3/admin/users/actions-admin/authorizations: 404 Not Found []
Failed to impersonate Actions admin user.

The exact same command-line arguments seem to work for the main branch:

INFO[0000] Starting CodeQL Action sync tool version development... 
WARN[0000] https://simon-engledew-3c263321b.service.bpdev-us-east-1.github.net/api/v3 redirected to https://simon-engledew-3c263321b.service.bpdev-us-east-1.github.net/api/v3. The URL https://simon-engledew-3c263321b.service.bpdev-us-east-1.github.net/api/v3/ will be used for all API requests. 
DEBU[0000] Ensuring repository exists...                
DEBU[0001] Repository does not exist. Creating it... 

My token has site_admin, repo, admin:org and workflow

@chrisgavin
Copy link
Collaborator Author

Thanks @simon-engledew! I had the arguments to IsMember in the wrong order. 🤦

@simon-engledew
Copy link
Contributor

Ok, that seems to have worked!

@chrisgavin chrisgavin merged commit 197081f into main Mar 25, 2021
@chrisgavin chrisgavin deleted the check-org-membership-api branch March 25, 2021 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants