OAuth consumer (sign in / sign up with external provider)
Sign in / sign up via external OAuth provider.
Setup:
-
OAUTH_CONSUMER_STRATEGIES="twitter facebook google microsoft" mix deps.get
-
In
config/dev.secret.exs
(note extra config statement formicrosoft
strategy):
config :ueberauth, Ueberauth.Strategy.Twitter.OAuth,
consumer_key: System.get_env("TWITTER_CONSUMER_KEY"),
consumer_secret: System.get_env("TWITTER_CONSUMER_SECRET")
config :ueberauth, Ueberauth.Strategy.Facebook.OAuth,
client_id: System.get_env("FACEBOOK_APP_ID"),
client_secret: System.get_env("FACEBOOK_APP_SECRET"),
redirect_uri: System.get_env("FACEBOOK_REDIRECT_URI")
config :ueberauth, Ueberauth.Strategy.Google.OAuth,
client_id: System.get_env("GOOGLE_CLIENT_ID"),
client_secret: System.get_env("GOOGLE_CLIENT_SECRET"),
redirect_uri: System.get_env("GOOGLE_REDIRECT_URI")
config :ueberauth, Ueberauth.Strategy.Microsoft.OAuth,
client_id: System.get_env("MICROSOFT_CLIENT_ID"),
client_secret: System.get_env("MICROSOFT_CLIENT_SECRET")
config :ueberauth, Ueberauth,
providers: [
microsoft: {Ueberauth.Strategy.Microsoft, [callback_params: []]}
]
-
For Twitter, register an app at https://developer.twitter.com/en/apps, configure callback URL to
https://<your_host>/oauth/twitter/callback
-
For Facebook, register an app at https://developers.facebook.com/apps, configure callback URL to
https://<your_host>/oauth/facebook/callback
, enable Facebook Login service at https://developers.facebook.com/apps/<app_id>/fb-login/settings/ -
For Google, register an app at https://console.developers.google.com, configure callback URL to
https://<your_host>/oauth/google/callback
-
For Microsoft, register an app at https://portal.azure.com, configure callback URL to
https://<your_host>/oauth/microsoft/callback
-
Start server with
OAUTH_CONSUMER_STRATEGIES="twitter facebook google microsoft" TWITTER_CONSUMER_KEY="..." TWITTER_CONSUMER_SECRET="..." FACEBOOK_APP_ID="..." FACEBOOK_APP_SECRET="..." FACEBOOK_REDIRECT_URI="..." GOOGLE_CLIENT_ID="..." GOOGLE_CLIENT_SECRET="..." GOOGLE_REDIRECT_URI="..." MICROSOFT_CLIENT_ID="..." MICROSOFT_CLIENT_SECRET="..." mix phx.server
-
https://<your_host>/web/ will have "Sign in with ..." option for each strategy listed in
OAUTH_CONSUMER_STRATEGIES
.