-
Notifications
You must be signed in to change notification settings - Fork 92
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
Get new access token via refresh token API #730
Conversation
@albeja - Thanks for this! I'll review as soon as I have a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for this! A few changes to make are detailed above. If you're able to add tests as well, that would be helpful but I see that the exchange code class is untested so you don't have a great example to use.
/** | ||
* Make the API call and handle the response. | ||
* | ||
* @param string|null $code - Authorization code to exchange for tokens. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be updated with actual method params
->add_body( 'refresh_token', $refresh_token ) | ||
->post() | ||
->handle_response( __METHOD__ ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WP_Auth0_ErrorManager::insert_auth0_error( | ||
__METHOD__ . ' L:' . __LINE__, | ||
__( 'An /oauth/token call triggered a 401 response from Auth0. ', 'wp-auth0' ) . | ||
__( 'Please check the Client Secret saved in the Auth0 plugin settings. ', 'wp-auth0' ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__( 'Please check the Client Secret saved in the Auth0 plugin settings. ', 'wp-auth0' ) | |
__( 'Please check the Client ID and Client Secret saved in the Auth0 plugin settings. ', 'wp-auth0' ) |
Implemented minor changes from Josh's review. Co-Authored-By: Josh Cunningham <josh@joshcanhelp.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one last suggestion and I think we're good here. I don't mind handling the tests for this, along with the auth code exchange as well.
If you have any working code samples for using this, though, that would be helpful to have in the PR description.
Thank you once again!
Co-Authored-By: Josh Cunningham <josh@joshcanhelp.com>
Wonderful! Unfortunately I have difficulties with my local phpunit-environment at the moment. That's why I did not write any tests so far. |
@albeja - I'll leave this open for now so you can add those tests. Let me know if you need any guidance setting up the testing suite beyond the docs we have. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot this was still open. Thanks again for the contribution @albeja!
Added a class for requesting a new access token via the refresh token (as old "get_token()"-method was deprecated and deleted lately).
Followed the coding style from
WP_Auth0_Api_Exchange_Code.php
.