Single Sign on Feature with Google Account using PHP

2.2k Views Asked by At

I will have username and password of gmail I want to develop an application in which i have an login in my site.When i do login in my site . I must get automatically login into gmail.There must be a link when the user clicks on the link he must be automatically get login into the site. I will demonstrate it with am example

Username:XXXXX Password:XXXXX

Click here to go to gmail

It will be something like above on my Website. When user enters the Username and password And gets login and if he clicks on the link.He must be able to see his gmail account.I mean to say he must be login to gmail.

1

There are 1 best solutions below

0
On

This is a terrible idea, in order for your system to even attempt to log on to gmail - you would have to have access to your users' password in plain text format at some point. That means, the password would either be stored as it is or you'd have to use an encryption function rather than hashing one to save the password within your db. At some point, you'd have to decrypt and send plaintext password for gmail logon.

So why not reverse the logic? Why not have the user logged on to your site if they are logged on to gmail? Mechanism for doing such a thing exists for years, it's called OpenID and even SO uses it. I suggest reading up on that rather than potentially screwing up someone's data with poorly designed system.