okpy / ok-client

A Python client for the OK autograding system
https://okpy.org/
Apache License 2.0
57 stars 42 forks source link

ERROR invalid_grant #450

Open davidwagner opened 4 years ago

davidwagner commented 4 years ago

We have dozens of students in Data 8 who have experienced

ERROR | auth.py:102 | {'error': 'invalid_grant'}

when trying to log into okpy from a Jupyter notebook (_ = ok.auth(inline=True)). I can't track down any commonality into what is causing this. The workaround/hack we have been using is to add force=True, but that is not ideal because then it requires them to reauthenticate every time. Also it seems like a kludge to paper over an issue, and it would be nice to understand what is causing this problem and fix it.

How would I go about debugging / troubleshooting this?

rahularya50 commented 4 years ago

I'd suggest following the instructions in the README to get a copy of OKPy running locally that's built from this repo. Then put some print statements in https://github.com/okpy/ok-client/blob/master/client/utils/auth.py to see where reauthentication is failing.

rahularya50 commented 4 years ago

It might be that the reauthentication process does not take into consideration Jupyter notebooks, since that error is what you get when your token has expired on the CLI client.

rahularya50 commented 4 years ago
        try:
            access_token = refresh_local_token(server)
        except OAuthException as e:
            # Account for Invalid Grant Error During make_token_post
            if not silent:
                raise e
            return notebook_authenticate(cmd_args, force=True, silent=False)

is what might not be working. Check to see if it's even reaching this point?