Omniauth_3.0


License

License

GroupId

GroupId

com.github.ricsirigu
ArtifactId

ArtifactId

omniauth_3.0_2.11
Last Version

Last Version

0.18
Release Date

Release Date

Type

Type

jar
Description

Description

Omniauth_3.0
Omniauth_3.0
Project URL

Project URL

https://github.com/ricsirigu/lift-omniauth
Project Organization

Project Organization

com.github.ricsirigu
Source Code Management

Source Code Management

https://github.com/ricsirigu/lift-omniauth.git

Download omniauth_3.0_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.ricsirigu/omniauth_3.0_2.11/ -->
<dependency>
    <groupId>com.github.ricsirigu</groupId>
    <artifactId>omniauth_3.0_2.11</artifactId>
    <version>0.18</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.ricsirigu/omniauth_3.0_2.11/
implementation 'com.github.ricsirigu:omniauth_3.0_2.11:0.18'
// https://jarcasting.com/artifacts/com.github.ricsirigu/omniauth_3.0_2.11/
implementation ("com.github.ricsirigu:omniauth_3.0_2.11:0.18")
'com.github.ricsirigu:omniauth_3.0_2.11:jar:0.18'
<dependency org="com.github.ricsirigu" name="omniauth_3.0_2.11" rev="0.18">
  <artifact name="omniauth_3.0_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.ricsirigu', module='omniauth_3.0_2.11', version='0.18')
)
libraryDependencies += "com.github.ricsirigu" % "omniauth_3.0_2.11" % "0.18"
[com.github.ricsirigu/omniauth_3.0_2.11 "0.18"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.11
net.databinder : dispatch-core_2.11 jar 0.8.10
net.databinder : dispatch-http_2.11 jar 0.8.10
net.databinder : dispatch-oauth_2.11 jar 0.8.10
net.databinder : dispatch-http-json_2.11 jar 0.8.10

provided (1)

Group / Artifact Type Version
net.liftweb : lift-webkit_2.11 jar 3.0-SNAPSHOT

Project Modules

There are no modules declared in this project.

Lift-Omniauth Module

Usage

in Boot.scala

import omniauth.lib._
...
//Add Omniauth to the sitemap
Omniauth.sitemap
//init
//Supply a list of providers
Omniauth.initWithProviders(List(new FacebookProvider("key", "secret")))
//or init with providers in properties
Omniauth.init

define your client id (key) and secret for each provider you will use in your props file(s) or as JVM system properties

omniauth.facebooksecret=...
omniauth.facebookkey=...

set the base URL for your application

omniauth.baseurl=http://localhost:8080/

set the success and failure URLs

omniauth.successurl=/
omniauth.failureurl=/error

For Facebook provider you can set permissions. For example:

omniauth.facebookpermissions=email,read_stream

Redirect the user to the auth URL in your application:

S.redirectTo("/auth/facebook/signin")

You can optionally specify where the user should return to after successful authentication:

S.redirectTo("/auth/facebook/signin?returnTo=%2Ftimeline%3FshowComments%3Dtrue")

After a user has logged into an auth provider you can access data through the session var Omniauth.currentAuth

Omniauth.currentAuth match {
  case Full(auth:AuthInfo) => 
  case _ =>
}

You can also use obtain a user's unique ID from a provider without using sessions using Omniauth.tokenToId(provider:String, token:String): Box[String]

Omniauth.tokenToId("facebook", token) match {
  case Full(uid) => user.doSomethingWithFacebookId(uid)
}

Finally redirect the user back to the appropriate place in the application, using the optional returnTo variable:

val url = Omniauth.returnTo.openOr("/")
S.redirectTo(url)

Installation

A big thank you to jonoabroad for hosting builds to make using much easier.

To include this module in your Lift project, update your libraryDependencies in build.sbt to include:

libraryDependencies ++= {
  val liftEdition = "2.5" // Also supported: "2.6" and "3.0"

  Seq(
    // Other dependencies ...
    "net.liftmodules" %% ("omniauth_"+liftEdition) % "0.17" % "compile"
  )
}

Supported Versions

Lift-OmniAuth is built and released to support Lift edition 2.5 with Scala versions 2.9.1, 2.9.1-1, 2.9.2, and 2.10; Lift edition 2.6 with Scala versions 2.9.1, 2.9.1-1, 2.9.2, 2.10, 2.11; and Lift edition 3.0 with Scala version 2.11. This project's scala version is purposefully set at the lowest common denominator to ensure each version compiles.

Providers

Lift-OmniAuth currently supports the following external providers:

  • via OAuth
    • Facebook
    • Twitter
    • Github
    • MSLive
    • Dropbox
    • Linkedin
    • Google+
    • Instagram
    • VK
    • Kuaipan(金山快盘/迅雷快盘)

Tutorials

Joe Barnes has written Dropbox tutorial.

Versions

Version
0.18
0.17