Skip to content

Error when authenticated through OAuth without the user scope #797

Closed
@baldychristophe

Description

@baldychristophe

Hi,

According to the github documentation, the API return on /user is different when the user is authenticated through OAuth without the user scope from when it is authenticated with the user scope.
https://developer.github.com/v3/users/#get-the-authenticated-user

But the library seems to handle only users with the user scope.

When the user scope is not used, the api returns fewer fields: for instance, the disk_usage field is not returned, and when trying to load the return into an AuthenticatedUser here:

github3.py/github3/github.py

Lines 1004 to 1019 in bf44c16

@requires_auth
def me(self):
"""Retrieve the info for the authenticated user.
.. versionadded:: 1.0
This was separated from the ``user`` method.
:returns:
the representation of the authenticated user.
:rtype:
:class:`~github3.users.AuthenticatedUser`
"""
url = self._build_url('user')
json = self._json(self._get(url), 200)
return self._instance_or_null(users.AuthenticatedUser, json)

I get the following error:

IncompleteResponse: None The library was expecting more data in the response (KeyError('disk_usage',)). Either GitHub modified it's response body, or your token is not properly scoped to retrieve this information.

I think this function should not always try to load the result into an AuthenticatedUser, but first check the fields of the API's response and try to load a User if some fields are missing.

Because of this behavior, we have to keep using the version 1.0.0a4 and cannot upgrade to version 1.0.1

If you think this is a valid issue, I can work on a pull request to fix it.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions