A
A
Alexander2015-12-29 13:53:29
Facebook
Alexander, 2015-12-29 13:53:29

How to properly build oauth registration logic?

Good afternoon!
I register through social networks. I can't figure out how to build a proper script with redirects.
For example, let's take VK.
Required data from the user: first name, last name, email, phone. It would be cool to authorize without reloading the page (via Open API), but then you can’t get an email (do I understand correctly?).
Social phone number networks do not give, so we will request it additionally, after successful authorization through the social network.
Step 1: show the window
3c742bebf6.png
Step 2: When you click the VK icon, redirect the browser to:

http://oauth.vk.com/authorize?client_id=XXX&redirect_uri=http://mysite.ru/oauth.php&response_type=code&display=popup&scope=email

Step 3: In the mysite.ru/oauth.php script, we get $_GET['code'] and make requests to the VK API to get user data.
Step 4: Return the user to the registration form to complete it.
4. 1. How can we return the user's browser back to the page with our registration form and pass information about the logged in user to it?
4. 2. Is there a registration form called by a modal window from any page of the site? - Then the dynamic registration form URL is obtained.
42ac6fd0a3.png
And in general, do I understand the principle correctly?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2015-12-29
@librown

Click on the button to open the link in a new window
All redirects are made in this window and then your page is returned in which your javascript will be

var vk = window.opener.document.getElementById('vklogin');
vk.fnOnVkAuth(email);

Gets the element in the main window and calls the function you pinned, which will close the new window
and continue with your script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question