I suggest adding something like this to check if a github user is part of a team (similar to check if a user is part of an organization.
GITHUB_TEAM_MEMBER_OF_URL = 'https://api.github.com/teams/{team_id}/members/{username}'
And then something like this:
# If we have a github team id defined, test that the current user
# is a member of that team.
if data and self.GITHUB_TEAM_ID:
member_url = GITHUB_TEAM_MEMBER_OF_URL.format(
username=data.get('login'),
team_id=self.GITHUB_TEAM_ID,
) + '?' + urlencode({
'access_token': access_token
})
try:
response = dsa_urlopen(member_url)
except HTTPError:
raise AuthFailed(self, 'User doesn\'t belong to the team')
else:
if response.code != 204:
raise AuthFailed('User doesn\'t belong to the team')
I created a working solution with the above code for django-social-auth==0.7.28. If there are more 0.7.* versions planned please add it there as well.
I suggest adding something like this to check if a github user is part of a team (similar to check if a user is part of an organization.
And then something like this:
I created a working solution with the above code for
django-social-auth==0.7.28. If there are more 0.7.* versions planned please add it there as well.