D
D
Danil Chekalin2015-01-19 01:17:44
Facebook
Danil Chekalin, 2015-01-19 01:17:44

How to make email mandatory for oAuth providers?

Google+ gives email without any questions. But Vk and Facebook, in my case, allow you to prohibit giving email to the service. Moreover, Vk does not give back at all, not even the user rejects the transmission of email. On other sites I saw implementations, both in Facebook and Vk (seemingly), where the user is required to provide an email

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Askar Familiev, 2015-01-20
@dakiesse

I just recently worked with this
solution, it’s just that there will be a lot of code if I post it here, I’ll
describe everything like this, if it’s not clear, ask, I’ll answer
in general facebook: yes, there is such nonsense here that the social network itself allows you to uncheck the user, but there is an API a method that can find out what rights this user has given us, namely
/me/permissions?access_token=
if in the response from the API, in the array for email status == decline - then there are no rights, if granted - that is,
if not, you can request access to email again

header("HTTP/1.1 302 Found");
header(
'Location: '.$cfg['urls']['authorize_endpoint'].
'auth_type=rerequest&'.//этот парам. указывает что надо сделать перезапрос доступа к email пользователя (не получится отказать в доступе к email)
'client_id='.$cfg['client_id'].'&'.
'response_type='.$cfg['response_type'].'&'.
'state='.$cfg['state'].'&'.
'scope='.$cfg['scope'].'&'.
'redirect_uri='.$cfg['urls']['redirect_uri']);

here the user will not be able to uncheck the box, either OK or CANCEL
as for VK:
everything is also easy, use OAuth 2.0
header("HTTP/1.1 302 Found");
header(
'Location: '.$cfg['urls']['authorize_endpoint'].
'client_id='.$cfg['client_id'].'&'.
'response_type='.$cfg['response_type'].'&'.
'scope=email&'.//вот оно то место, где ты запрашиваешь email
'v='.$cfg['v'].'&'.
'redirect_uri='.$cfg['urls']['redirect_uri']);

if you use OAuth 2.0, you can't uncheck the email box there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question