tl-its-umich-edu / canvas-app-explorer

A Web application that presents a list of Canvas external (LTI) tools with details. When integrated within Canvas, the user can search for specific LTI tool(s), and add or remove those tools from Canvas courses.
Apache License 2.0
4 stars 6 forks source link

If refresh token is invalid, rather than returning invalid_grant, just remove token and retry #208

Closed jonespm closed 2 years ago

jonespm commented 2 years ago

I believe that when calling this get_oauth_token code if the access token is invalid it ends up printing Error: refresh_token request failed to get a token: Error: invalid_grant

We'd ideally want it to try to remove this users token and try the process again. It's possible that something changed that caused the token to become invalid and clearing it automatically would fix it.

I'm not 100% sure where the error is pushed up from but we'd have to investigate a little and hopefully can take care if it in our code rather than the library.

To reproduce

Expectation is that it does one refresh to try to clear out and retry rather than just fail.

We may also want to test the case if the user removes their token from Canvas, it should be able to handle this.

This workaround is currently referenced at the bottom of the wiki with a manual workaround.

TEST PLAN:

zqian commented 2 years ago

I think this error occurs after the Canvas test instance reset, which invalidates the old Canvas OAuth2 token?

jonespm commented 2 years ago

Yes, this will also happen after every Canvas test refresh. I'm not sure if there's other cases it could happen. We haven't tested many exception cases for OAuth.

roujiawang commented 2 years ago

Performed tests according to the TEST PLAN No unexpected behavior found.