Todoist OAuth2 strategy for Überauth.
-
Setup your application at Todoist App Management.
-
Add
:ueberauth_todoistto your list of dependencies inmix.exs:def deps do [{:ueberauth_todoist, "~> 1.0"}] end
-
Add Todoist to your Überauth configuration:
config :ueberauth, Ueberauth, providers: [ todoist: {Ueberauth.Strategy.Todoist, []} ]
-
Update your provider configuration:
config :ueberauth, Ueberauth.Strategy.Todoist.OAuth, client_id: System.get_env("TODOIST_CLIENT_ID"), client_secret: System.get_env("TODOIST_CLIENT_SECRET")
Or, to read the client credentials at runtime:
config :ueberauth, Ueberauth.Strategy.Todoist.OAuth, client_id: {:system, "TODOIST_CLIENT_ID"}, client_secret: {:system, "TODOIST_CLIENT_SECRET"}
-
Include the Überauth plug in your controller:
defmodule MyApp.AuthController do use MyApp.Web, :controller pipeline :browser do plug Ueberauth ... end end
-
Create the request and callback routes if you haven't already:
scope "/auth", MyApp do pipe_through :browser get "/:provider", AuthController, :request get "/:provider/callback", AuthController, :callback end
-
Your controller needs to implement callbacks to deal with
Ueberauth.AuthandUeberauth.Failureresponses.
For an example implementation see the Überauth Example application.
Depending on the configured url you can initiate the request through:
/auth/todoist
Or with options:
/auth/todoist?scope=data:read
Scope can be configured either explicitly as a scope query value on the request path or in your configuration:
config :ueberauth, Ueberauth,
providers: [
github: {Ueberauth.Strategy.Todoist, [default_scope: "data:read"]}
]Please see LICENSE for licensing details.