-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
twitter.ex
40 lines (34 loc) · 1.08 KB
/
twitter.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
defmodule Assent.Strategy.Twitter do
@moduledoc """
Twitter OAuth strategy.
The Twitter user endpoint only returns verified email, `email_verified` will
always be `true`.
## Usage
config = [
consumer_key: "REPLACE_WITH_CONSUMER_KEY",
consumer_secret: "REPLACE_WITH_CONSUMER_SECRET"
]
See `Assent.Strategy.OAuth` for more.
"""
use Assent.Strategy.OAuth.Base
@impl true
def default_config(_config) do
[
site: "https://api.twitter.com",
user_url: "/1.1/account/verify_credentials.json?include_entities=false&skip_status=true&include_email=true",
]
end
@impl true
def normalize(_config, user) do
{:ok, %{
"sub" => user["id"],
"name" => user["name"],
"preferred_username" => user["screen_name"],
"profile" => "https://twitter.com/#{user["screen_name"]}",
"picture" => user["profile_image_url_https"],
"website" => user["url"],
"email" => user["email"],
"email_verified" => true
}}
end
end