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

Only extract the needed token information #21

Closed
wants to merge 1 commit into from

Conversation

ekohl
Copy link
Contributor

@ekohl ekohl commented Jul 18, 2019

According to the documentation the result can contain:

  • token
  • expires_at
  • permissions
  • repositories

Currently it doesn't care about the additional attributes, but it is
making the application fail:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/asyncio/runners.py", line 43, in run
        return loop.run_until_complete(main)
      File "/usr/local/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
        return future.result()
      File "/usr/local/lib/python3.7/site-packages/octomachinery/app/server/machinery.py", line 43, in run_forever
        async with GitHubApp(config.github) as github_app:
      File "/usr/local/lib/python3.7/site-packages/octomachinery/github/api/app_client.py", line 69, in __aenter__
        self._installations = await self.get_installations()
      File "/usr/local/lib/python3.7/site-packages/octomachinery/github/api/app_client.py", line 162, in get_installations
        await installations[install.id].retrieve_access_token()
      File "/usr/local/lib/python3.7/site-packages/octomachinery/github/entities/app_installation.py", line 49, in retrieve_access_token
        accept='application/vnd.github.machine-man-preview+json',
    TypeError: __init__() got an unexpected keyword argument 'permissions'

This started to show up when the application was made public and added
to another organization.

According to the documentation the result can contain:

* token
* expires_at
* permissions
* repositories

Currently it doesn't care about the additional attributes, but it is
making the application fail:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/asyncio/runners.py", line 43, in run
        return loop.run_until_complete(main)
      File "/usr/local/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
        return future.result()
      File "/usr/local/lib/python3.7/site-packages/octomachinery/app/server/machinery.py", line 43, in run_forever
        async with GitHubApp(config.github) as github_app:
      File "/usr/local/lib/python3.7/site-packages/octomachinery/github/api/app_client.py", line 69, in __aenter__
        self._installations = await self.get_installations()
      File "/usr/local/lib/python3.7/site-packages/octomachinery/github/api/app_client.py", line 162, in get_installations
        await installations[install.id].retrieve_access_token()
      File "/usr/local/lib/python3.7/site-packages/octomachinery/github/entities/app_installation.py", line 49, in retrieve_access_token
        accept='application/vnd.github.machine-man-preview+json',
    TypeError: __init__() got an unexpected keyword argument 'permissions'

This started to show up when the application was made public and added
to another organization.

[1]: https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/
@ekohl
Copy link
Contributor Author

ekohl commented Jul 18, 2019

Right after deploying this (because the application was failing to start up) I saw a permission error because of an incorrect token so this may still have an issue.

It may also be cleaner to store the values of the data we expect.

@webknjaz
Copy link
Member

Well... The attrs class also kinda acts as a validation layer. I need to think about it.

self._metadata.access_tokens_url,
data=b'',
accept='application/vnd.github.machine-man-preview+json',
)))
)
self._token = GitHubInstallationAccessToken(token=result['token'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a band-aid... Maybe it needs to be redesigned but for now, I'd definitely want to see the new structure reflected in the model class.

@webknjaz
Copy link
Member

This started to show up when the application was made public and added
to another organization.

It's a coincidence. I have a public app and it was fine up until yesterday. This API endpoint is marked as preview effectively meaning that they can change it whenever they like without any prior notice.

@webknjaz
Copy link
Member

Note: now sure whether the app should crash if such exception appears.

@webknjaz webknjaz closed this Jul 28, 2019
@webknjaz webknjaz reopened this Jul 28, 2019
@webknjaz
Copy link
Member

Apparently, there's also undocumented repository_selection: 0b6b9cd

@ekohl
Copy link
Contributor Author

ekohl commented Aug 3, 2019

Confirmed that with version 0.0.17 it works.

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.

None yet

2 participants