I have a wordpress based website where I need to implement OAuth2 to give the users the ability to use their account to login into other sites. I've tried to install different plugins to achive this, and one plugin will fail to activate due to a fatal error and the second will not give me the ability to fully customize the field returned after an user is authenticated.
I'm thinking to implement this library and setup the server with a custom plugin. My pseudo code looks like the following but I need to improve it a lot
<?php
register_rest_route(
'myPlugin/v1',
'/auth',
array(
'methods' => 'POST',
'callback' => array($this, 'authenticate_user')
)
);
function authenticate_user(WP_REST_Request $request)
{
//oauth library code here
}
?>
I'm not sure if to implement this correctly I just need to setup some routes. What I see into the plugins documentations is that every plugin will have at least three routes, one for the token, one for authorization and one that will return the informations about the logged user.
Can anyone give me some tips about the implementation? How many routes I will need to achive my scope?
source https://stackoverflow.com/questions/73991105/wordpress-implement-oauth2-using-custom-plugin
No comments:
Post a Comment