Skip to content

Latest commit

 

History

History
90 lines (61 loc) · 2.13 KB

README.md

File metadata and controls

90 lines (61 loc) · 2.13 KB

Überauth Mailchimp

Mailchimp OAuth2 strategy for Überauth.

Installation

  1. Setup your application at Mailchimp API.

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

    def deps do
      [{:ueberauth_mailchimp, "~> 0.6"}]
    end
  3. Add the strategy to your applications:

    def application do
      [applications: [:ueberauth_mailchimp]]
    end
  4. Add Mailchimp to your Überauth configuration:

    config :ueberauth, Ueberauth,
      providers: [
        mailchimp: {Ueberauth.Strategy.Mailchimp, []}
      ]
  5. Update your provider configuration:

    config :ueberauth, Ueberauth.Strategy.Mailchimp.OAuth,
      client_id: System.get_env("MAILCHIMP_CLIENT_ID"),
      client_secret: System.get_env("MAILCHIMP_CLIENT_SECRET")
  6. Include the Überauth plug in your controller:

    defmodule MyApp.AuthController do
      use MyApp.Web, :controller
      plug Ueberauth
      ...
    end
  7. 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
  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 initiate the request through:

/auth/mailchimp

Or with options:

/auth/mailchimp?scope=users:read

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

config :ueberauth, Ueberauth,
  providers: [
    mailchimp: {Ueberauth.Strategy.Mailchimp, [default_scope: "users:read,users:write"]}
  ]

License

Please see LICENSE for licensing details.