ueberauth/ueberauth_facebook

Name: ueberauth_facebook

Owner: ueberauth

Description: Facebook OAuth2 Strategy for Überauth.

Created: 2015-11-15 20:13:58.0

Updated: 2018-01-07 08:43:25.0

Pushed: 2017-09-21 22:41:07.0

Homepage:

Size: 52

Language: Elixir

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Überauth Facebook

Build Status Hex Version License

Facebook OAuth2 strategy for Überauth.

Installation
  1. Setup your application at Facebook Developers.

  2. Add :ueberauth_facebook to your list of dependencies in mix.exs:

    deps do
    :ueberauth_facebook, "~> 0.7"}]
    
    
  3. Add the strategy to your applications:

    application do
    pplications: [:ueberauth_facebook]]
    
    
  4. Add Facebook to your Überauth configuration:

    ig :ueberauth, Ueberauth,
    oviders: [
    facebook: {Ueberauth.Strategy.Facebook, []}
    
    
  5. Update your provider configuration:

    ig :ueberauth, Ueberauth.Strategy.Facebook.OAuth,
    ient_id: System.get_env("FACEBOOK_CLIENT_ID"),
    ient_secret: System.get_env("FACEBOOK_CLIENT_SECRET")
    
  6. Include the Überauth plug in your controller:

    odule MyApp.AuthController do
    e MyApp.Web, :controller
    ug Ueberauth
    .
    
    
  7. Create the request and callback routes if you haven't already:

    e "/auth", MyApp do
    pe_through :browser
    
    t "/:provider", AuthController, :request
    t "/:provider/callback", AuthController, :callback
    
    
  8. Your controller needs to implement callbacks to deal with Ueberauth.Auth and Ueberauth.Failure responses.

For an example implementation see the Überauth Example application.

Calling

Depending on the configured URL you can initialize the request through:

/auth/facebook

Or with options:

/auth/facebook?scope=email,public_profile

By default the requested scope is “public_profile”. Scope can be configured either explicitly as a scope query value on the request path or in your configuration:

ig :ueberauth, Ueberauth,
oviders: [
facebook: {Ueberauth.Strategy.Facebook, [default_scope: "email,public_profile,user_friends"]}

Additionally you can now specify the display param to pass to Facebook:

ig :ueberauth, Ueberauth,
oviders: [
facebook: {Ueberauth.Strategy.Facebook, [
  default_scope: "email,public_profile,user_friends",
  display: "popup"
]}

display can be the following values: page (default), async, iframe, popup, touch, wap

Starting with Graph API version 2.4, Facebook has limited the default fields returned when fetching the user profile. Fields can be explicitly requested using the profile_fields option:

ig :ueberauth, Ueberauth,
oviders: [
facebook: {Ueberauth.Strategy.Facebook, [profile_fields: "name,email,first_name,last_name"]}

See Graph API Reference > User for full list of fields.

License

Please see LICENSE for licensing details.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.