OAuth1 based providers

To configure OAuth1 based providers you must use the OAuth1Settings class. This class has the following form:

case class OAuth1Settings(
  requestTokenURL: String,
  accessTokenURL: String,
  authorizationURL: String,
  callbackURL: String,
  apiURL: Option[String] = None,
  consumerKey: String,
  consumerSecret: String)
PropertyDescription
requestTokenURLThe request token URL provided by the OAuth provider
accessTokenURLThe access token URL provided by the OAuth provider
authorizationURLThe authorization URL provided by the OAuth provider
callbackURLThe callback URL to the application after a successful authentication on the OAuth provider. The URL can be a relative path which will be resolved against the current request's host
apiURLThe URL to fetch the profile from the API. Can be used to override the default URL hardcoded in every provider implementation.
consumerKeyThe consumer ID provided by the OAuth provider
consumerSecretThe consumer secret provided by the OAuth provider

Callback URL

The callbackURL must point to your action which is responsible for
the authentication over your defined providers. So if you define the
following route as example:

GET  /authenticate/:provider  @controllers.SocialAuthController.authenticate(provider)

Then your callbackURL must have the following format:

callbackURL="https://your.domain.tld/authenticate/linkedin"

Example

linkedin {
  requestTokenURL="https://api.linkedin.com/uas/oauth/requestToken"
  accessTokenURL="https://api.linkedin.com/uas/oauth/accessToken"
  authorizationURL="https://api.linkedin.com/uas/oauth/authenticate"
  callbackURL="https://your.domain.tld/authenticate/linkedin"
  consumerKey="your.consumer.key"
  consumerSecret="your.consumer.secret"
}

twitter {
  requestTokenURL="https://twitter.com/oauth/request_token"
  accessTokenURL="https://twitter.com/oauth/access_token"
  authorizationURL="https://twitter.com/oauth/authenticate"
  callbackURL="https://your.domain.tld/authenticate/twitter"
  consumerKey="your.consumer.key"
  consumerSecret="your.consumer.secret"
}

xing {
  requestTokenURL="https://api.xing.com/v1/request_token"
  accessTokenURL="https://api.xing.com/v1/access_token"
  authorizationURL="https://api.xing.com/v1/authorize"
  callbackURL="https://your.domain.tld/authenticate/xing"
  consumerKey="your.consumer.key"
  consumerSecret="your.consumer.secret"
}

To get the consumerKey/consumerSecret keys you need to log into the developer site of each service and register your application.

Override the configuration locally

Basically the configuration of the providers will be done globally on provider instantiation. But in some circumstances it is necessary to override this globally configuration with other values. This can be done with the withSettings method that every SocialProvider has implemented. The withSettings methods accepts a function which gets the current configuration as parameter and which must return a new configuration.

provider.withSettings { config =>
  config.copy("new-value")
}.authenticate()

What’s Next