Hi guys!
I am developing an UWP App that it works as a Web App for a WordPress Blog.
In that site the OneAll plugin is installed and configurated for the social network integration.
My problem is:
I am not able to get the WordPress authentication working after the login with a social network.
The process that I follow is below
1. login with the social network SDK (for example Facebook). In this way I get an access_token;
2. import the user in OneAll site (with a PUT to
https://mydomain.api.oneall.com/users.json). The PUT succeeded without any problem and the user is registered;
3. in the case of Facebook, I have sent a GET request to
https://mysite/api/user/fb_connect/?access_token= in order to tell to WordPress that the user is logged in with a social network. This call returns with success and I get a wp_user_id and the other data.
It is seems all right, but when I try to check if I am really logged in (with the request to
http://mysite/wp-json/wp/v2/users/me), I get that I'm not connected... and it is true!
In fact, I am not able to post any comments or do anything that require authentication.
I think that I need to validate the access token or get a connection token in some way.
What it is missing?
Thank you,
Best Regards
Answers
success
and also thewp_user_id
then theaccess_token
is correct and you should look at the code of that page and check if it actually logs the user in. Maybe it only returns the wp_user_id.You can login a user like this in WordPress:
$user_data = get_userdata ($user_id); wp_clear_auth_cookie (); wp_set_auth_cookie ($user_data->ID, true); do_action ('wp_login', $user_data->user_login, $user_data);
thank you for your answer.
Reading your PHP code, It seems that I have to use a cookie.
I'm sorry but I can't use any cookie (I'm developing an Universal Windows App with C#/XAML).
I would lilke to know how to do this with some REST API calls.
Is it possible?
I have changed the way to do the authentication.
I have used the oAuth1.0 authentication with a WebBroker.
In this way I should exploit all the OneAll features!
When I have to get the authorization, I have set this callback
http://mydomain.api.oneall.com/socialize/callback.html
After the login with the social network, I get a state and a code...
Is one of theese the verifier token that I have to use for the final step (access) of the oAuth 1.0 process?
I have not got an access token...
Thank you
you cannot mix your own OAuth implementation with the OneAll callback. If you want to use your own OAuth implementation, then you also need to create your own callback script. State and code are part of the OAuth login. They need to be exchanged for an access_token by making a call to the social network API. This of course only if you use your own OAuth implementation.
If you use OneAll we take care the whole process.
I'm sorry but I'm working on a website where it is installed the OneAll plugin with with Freemium plan.
With the Freemium plan I cannot make a direct connection or invoke call for mobile like this
https://#your_subdomain#.api.oneall.com/socialize/connect/mobile/#provider_key#/?nonce=#nonce#&callback_uri=#callback_uri#
The "strange" matter of my authentication process is born by this situation.
In this case I recommend simply dropping this whole stuff: Then you use the OneAll plugin for Social Login. This will be less work and debugging.