0

I've downloaded the Google API PHP and I'm trying it out with a "log in with Google" script.every think i working fine. but i want password field as well,to save my database for further login as normal user for my web portal. i have use following code:

$service = new Google_Service_Oauth2($client); if ($client->getAccessToken()) { //For logged in user, get details from google using access token $user = $service->userinfo->get(); $user_id = $user['id'];} //list all user details echo '<pre>'; print_r($user); echo '</pre>'; 

and output of the $user is:

Google_Service_Oauth2_Userinfoplus Object ( [internal_gapi_mappings:protected] => Array ( [familyName] => family_name [givenName] => given_name [verifiedEmail] => verified_email ) [email] => [email protected] [familyName] => man [gender] => male [givenName] => deadman [hd] => [id] => 123456789012345 [link] => https://plus.google.com/101978174620808672845 [locale] => en-GB [name] => dead man [picture] => https://******************/photo.jpg [verifiedEmail] => 1 [modelData:protected] => Array ( [verified_email] => 1 [given_name] => dead [family_name] => man ) [processed:protected] => Array ( ) ) 

how to get password field from google?

1
  • Google is not going to give you that. If you want that you have to ask the user for it, or create one automatically and email it to them. Commented Feb 18, 2015 at 11:21

2 Answers 2

3

The entire point of Google Sign-In is so you don't store a password for the user. The user is able to use their Google credentials to access your site - Google is authenticating them for you and telling you who the user is. (Remember that Google authentication may not even involve a password for you to store. If the user has setup two-factor authentication, there is no password involved.)

If you want to allow your users to log into your site without a Google account, or in addition to their Google account, then you might want to prompt them for a password for your site, but this is completely outside Google's authentication system.

If you think you need a password to access the user's information on Google - you don't. For most services, you should be using OAuth 2 which provides a safer way for you and your users to manage what you can do using Google's services.

Sign up to request clarification or add additional context in comments.

1 Comment

i have accept you ans because you send me in right direction.. please visit the following site remind.com it will login with google account and after that user login as Normal user login.
1

You can not get password field of users in google auth or anyother social auth. This is for user security. There is a callback url option in console. User is redirected to that url if google login is authenticated.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.