okpy / ok-client

A Python client for the OK autograding system

Home Page:https://okpy.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR invalid_grant

davidwagner opened this issue · comments

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?

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.

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.

        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?