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

abc-init fails getting access token #507

Open
ozak opened this issue Aug 16, 2022 · 16 comments
Open

abc-init fails getting access token #507

ozak opened this issue Aug 16, 2022 · 16 comments

Comments

@ozak
Copy link

ozak commented Aug 16, 2022

Hi,

I am trying to test out abc-classroom for a new course. I tried setting up the Github access token following the instructions, but I am getting the following error:

abc-init
Setting up GitHub API access
Generating new access token
{'error': 'device_flow_disabled', 'error_description': 'Device Flow must be explicitly enabled for this App', 'error_uri': 'https://docs.github.com'}
Traceback (most recent call last):
  File "/Users/ozak/anaconda3/envs/EconGrowthUG/bin/abc-init", line 10, in <module>
    sys.exit(init())
  File "/Users/ozak/anaconda3/envs/EconGrowthUG/lib/python3.9/site-packages/abcclassroom/__main__.py", line 39, in init
    github.get_access_token()
  File "/Users/ozak/anaconda3/envs/EconGrowthUG/lib/python3.9/site-packages/abcclassroom/github.py", line 55, in get_access_token
    access_token = _poll_for_status(client_id, device_code)
  File "/Users/ozak/anaconda3/envs/EconGrowthUG/lib/python3.9/site-packages/abcclassroom/github.py", line 140, in _poll_for_status
    access_token = data["access_token"]
KeyError: 'access_token'

I saw in one of the discussions that one needs to install abc-classroom-bot in the organization, which I did.

image

But I still get the same error. Can you help?

@ozak
Copy link
Author

ozak commented Aug 17, 2022

Not sure if this is relevant?

@ozak
Copy link
Author

ozak commented Aug 17, 2022

I saw this discussion and gist that @kcranston opened. If I try the same code I get the following

import requests

client_id = "Iv1.8df72ad9560c774c"
header = {"Content-Type": "application/json", "Accept": "application/json"}

# Step 1
payload1 = {"client_id": client_id,}
r = requests.post(
    'https://github.com/login/device/code',headers=header,json=payload1
    )
data = r.json()

data

{'error': 'device_flow_disabled',
 'error_description': 'Device Flow must be explicitly enabled for this App',
 'error_uri': 'https://docs.github.com/'}

so it seems the abc-classroom-bot needs to have 'Device Flow manually enabled' as per this.

@ozak
Copy link
Author

ozak commented Aug 18, 2022

@kcranston @lwasser @pyup-bot @nkorinek can you help? Or do you know who is managing the abc-classroom-bot?

@kcranston
Copy link
Collaborator

Unfortunately, everyone you have tagged here is no longer with earthlab (and no longer has ownership access to the organization and the bot settings). I suspect you are correct about the device flow changes. One option would be to fork the repo and create your own github app (which would give you ownership over the settings).

@ozak
Copy link
Author

ozak commented Aug 18, 2022

I imagined that may be the case. So the code for the github app is in this repository? Sorry I have never used/created one.

@ozak
Copy link
Author

ozak commented Aug 19, 2022

@kcranston Is anyone on this list still at earthlab? https://github.com/orgs/earthlab/people

@ozak
Copy link
Author

ozak commented Aug 19, 2022

Can one of you help? @jdiax4302 @jlpalomino @joemcglinchy @jvtcl @mcattau

@fantasyEthan
Copy link

I encounter the same problem. @ozak Have you fixed this problem?

@kcranston
Copy link
Collaborator

I doubt that there is anyone with both knowledge of this repo and owner / admin privileges on this github organization. Your best approach would be to follow these instructions to create a new github app:

https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app

and then modify the client id to match your app here in your local copy of the code (ideally, this would be an environment variable instead of being hard-coded, but at this time we only had the earthlab-owned app):

https://github.com/earthlab/abc-classroom/blob/main/abcclassroom/auth.py#L110

@ozak
Copy link
Author

ozak commented Sep 14, 2022

@kcranston do you know which URLs are used? I planned on doing this but had no idea if I had to create a website for it or whether it is the Github link to the repo or what. There are a lot of technical things one has to fill that are not clear to me.

@kcranston
Copy link
Collaborator

You will want to select 'Device flow' during the setup (which is the command-line process for authorization). With this flow, the homepage and callback URL do not matter. I think you still need to enter something when you set up the all, but they aren't used in the process.

@ozak
Copy link
Author

ozak commented Sep 14, 2022

Thanks! I'll give it a try.

@ozak
Copy link
Author

ozak commented Sep 14, 2022

@kcranston do you know which permissions one needs to give? Do I need to give permissions on the user, org, or repo level? Seems the repo level permissions are for creating etc. Not sure about the other two.

@ozak
Copy link
Author

ozak commented Sep 14, 2022

@fantasyEthan if you want to try using my fork it seems it may be working. At least the basic part seems to go. I still have to check if I can create a new assignment etc, but do not have time right now.

pip uninstall abc-classroom
pip install git+https://github.com/ozak/abc-classroom

Let me know if you encounter any problems so I can change permissions if needed

@nkorinek
Copy link
Member

@ozak Hey! I'm so sorry for my late response, I am still maintaining this repo, just haven't checked in a while! I went ahead and enabled the device flow on the abc-classroom-bot, I hope that helps! Again, so sorry for how long this took, let me know if you try it out!

@ozak
Copy link
Author

ozak commented Sep 28, 2022

No problem. Luckily @kcranston provided guidance and I was able to create the app, and I think my fork is working now. Thanks none the less

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

No branches or pull requests

4 participants