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

GitHub token creation/nbinit #14

Closed
betatim opened this issue Dec 4, 2018 · 5 comments
Closed

GitHub token creation/nbinit #14

betatim opened this issue Dec 4, 2018 · 5 comments

Comments

@betatim
Copy link
Collaborator

betatim commented Dec 4, 2018

When running nbinit check localconfig.yaml for existing token and reuse it.

If there is no token then use something unique in the note for creating the token as we can't create two tokens with the same name.

@betatim
Copy link
Collaborator Author

betatim commented Dec 4, 2018

Alternatively place the token in ~/.abc.config and share it between all courses.

@lwasser
Copy link

lwasser commented Dec 14, 2018

Note - this is the error i get running nbinit when i already have a token (just for the record)

Traceback (most recent call last):
  File "/Users/leah-su/anaconda3/bin/nbinit", line 11, in <module>
    sys.exit(init())
  File "/Users/leah-su/anaconda3/lib/python3.6/site-packages/grading/__main__.py", line 60, in init
    two_factor_callback=two_factor)
  File "/Users/leah-su/anaconda3/lib/python3.6/site-packages/github3/api.py", line 26, in deprecation_wrapper
    return func(*args, **kwargs)
  File "/Users/leah-su/anaconda3/lib/python3.6/site-packages/github3/api.py", line 59, in authorize
    client_secret)
  File "/Users/leah-su/anaconda3/lib/python3.6/site-packages/github3/github.py", line 462, in authorize
    json = self._json(self._post(url, data=data), 201)
  File "/Users/leah-su/anaconda3/lib/python3.6/site-packages/github3/models.py", line 156, in _json
    raise exceptions.error_for(response)
github3.exceptions.UnprocessableEntity: 422 Validation Failed

@lwasser
Copy link

lwasser commented Dec 15, 2018

related to this is -- is this authorize() call deprecated? see here please. something odd is going on with the init command that i can't figure out .i seem to have to delete it each time or every so often. could be user error!

As it currently stands in the PR below, i just check for the config file in the template dir. if that contains the token then nbinit doesn't do anything. If not, it will authenticate and create a token.

NOTE - this will still fail if a token exists (i think??) as i believe authorize() makes a new token. I tried to figure out how to get a list of existing tokens and was having some issue with that. there is a check_auth method that i think might do what we want.

I think we want to

  1. check to see if a token exists in the file - do nothing if it's there - all good! maybe print a happy message
  2. If it's not there
    a. check to see if that token exists in the gh account. if it does, grab the token vals and add to yml
    b. if it's not there run authorize

@betatim
Copy link
Collaborator Author

betatim commented Dec 16, 2018

Good catch with the deprecation. I hadn't noticed this. Take a look at #40

@betatim
Copy link
Collaborator Author

betatim commented Dec 18, 2018

#40 doesn't quite close this issue as we still use a file local to the repository to store the token instead of placing it in ~/.abc.token (or some such). That is for another PR to solve.

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

2 participants