In this section, we are going to learn how to log a user into your application using his or her Gmail account.
Start a new blank project.
Register your app.
Edit the
build.sbt
file by adding the following dependencies:"net.databinder.dispatch" %% "dispatch-core" % "0.11.0"
Add the values of
client.id
andclient.secret
in thedefault.props
file.google.client.id=app-id google.client.secret=app=secret
Carry out the following steps to create a login mechanism using Gmail:
Create a file called
GoogleDispatcher.scala
inside thecode.lib
package.Create a
SessionVar
object calledgoogleSession
:object googleSession extends SessionVar[Box[String]](Empty)
Create a
SessionVar
object calledgoogleAuthState
:object googleAuthState extends SessionVar[Box[String]](Empty)
Create a
case
class calledAccessToken
:case class AccessToken(access_token: String, token_type: String, expires_in: Int, id_token: String)
Create a
case
class calledVerifiedEmail
...