使用Gmail登录时从社交名流获取电子邮件地址 [英] Get Email Address from socialite while login with Gmail

查看:229
本文介绍了使用Gmail登录时从社交名流获取电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注这篇文章,以 使用Google登录 .我能够成功重定向到gmail登录.此外,它会成功转到回调URL.

I am following this article to login with Google. I am able to redirect to gmail login successfully. Also, it goes to callback url successfully.

下面是我的代码

public function showGoogleLoginForm() {
    $providerKey = \Config::get('services.google');
    return \Socialite::driver( 'google' )->scopes(['profile', 'email'])->redirect();
}

问题

我现在正在尝试检查回调是否为我提供了用户的电子邮件地址.这样,我可以检查用户是否在我的数据库中注册.

I am now trying to check if the callback gives me the email address of the user or not. So that, I could check that user is registered in my database or not.

有没有办法在回调中获取电子邮件地址?

Is there any way to get the email address in the callback?

我能够将用户重定向到gmail登录,也可以使用回调方法.在回调方法中,此代码出现错误:\Socialite::driver( 'google' )->user()

I am able to redirect user to gmail login and also I am able to reach my callback method. In the callback method I got error on this code: \Socialite::driver( 'google' )->user()

当我使用此代码时,我得到了这个 错误 \Socialite::driver( 'google' )->user();

I got this Error when i used this code \Socialite::driver( 'google' )->user();

推荐答案

我必须启用Google + API才能消除此错误.现在一切正常.

I had to enable Google + API to get rid of this error. Everything is working perfectly now.

这篇关于使用Gmail登录时从社交名流获取电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆