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
Size: 52
Language: Elixir
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Facebook OAuth2 strategy for Überauth.
Setup your application at Facebook Developers.
Add :ueberauth_facebook
to your list of dependencies in mix.exs
:
deps do
:ueberauth_facebook, "~> 0.7"}]
Add the strategy to your applications:
application do
pplications: [:ueberauth_facebook]]
Add Facebook to your Überauth configuration:
ig :ueberauth, Ueberauth,
oviders: [
facebook: {Ueberauth.Strategy.Facebook, []}
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")
Include the Überauth plug in your controller:
odule MyApp.AuthController do
e MyApp.Web, :controller
ug Ueberauth
.
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
Your controller needs to implement callbacks to deal with Ueberauth.Auth
and Ueberauth.Failure
responses.
For an example implementation see the Überauth Example application.
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.
Please see LICENSE for licensing details.