D
D
Dmitry2016-05-24 08:04:17
Laravel
Dmitry, 2016-05-24 08:04:17

Laravel Socialite, Google provider - how to get user's age?

Good day.
Such a thing: I screwed the Socialite package from Taylor to the project. According to the TOR, the site user must specify the age to filter the available content. The provider for FB has no problems. But Google can not get the age in any way. I read the Doc, looked at the examples - the provider does not accept age, whatever one may say. Can anyone come across?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2016-05-24
Hrebet @hrebet

Check out the view of user resources returned by Google. Pay special attention to ageRange.min and ageRange.max .
As far as I understand, you need to change the mapUserToObject method of your provider in Socialite , extracting additional information. :-)

'age' => (integer) (array_get($user, 'ageRange')['min'] + array_get($user, 'ageRange')['max']) / 2,

D
Dmitry, 2016-05-25
@Astatroth

The question was solved from the side :) If there is a lack of mandatory data, the user will be prompted to specify them manually.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question