Class: Code0::Identities::Provider::Discord
- Inherits:
-
BaseOauth
- Object
- BaseOauth
- Code0::Identities::Provider::Discord
show all
- Defined in:
- lib/code0/identities/provider/discord.rb
Instance Attribute Summary
Attributes inherited from BaseOauth
#config_loader
Instance Method Summary
collapse
Methods inherited from BaseOauth
#initialize, #load_identity
Instance Method Details
#authorization_url ⇒ Object
23
24
25
|
# File 'lib/code0/identities/provider/discord.rb', line 23
def authorization_url
"https://discord.com/oauth2/authorize?client_id=#{config[:client_id]}&response_type=code&redirect_uri=#{URI.encode_uri_component(config[:redirect_uri])}&scope=identify+openid+email"
end
|
#create_identity(response) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/code0/identities/provider/discord.rb', line 27
def create_identity(response, *)
body = response.parsed_response
identifier = body["id"]
username = body["username"]
email = body["email"]
Identity.new(:discord, identifier, username, email, nil, nil)
end
|
#token_payload(code) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/code0/identities/provider/discord.rb', line 11
def token_payload(code)
{ code: code,
grant_type: "authorization_code",
redirect_uri: config[:redirect_uri],
client_id: config[:client_id],
client_secret: config[:client_secret] }
end
|
#token_url ⇒ Object
7
8
9
|
# File 'lib/code0/identities/provider/discord.rb', line 7
def token_url
"https://discord.com/api/oauth2/token"
end
|
#user_details_url ⇒ Object
19
20
21
|
# File 'lib/code0/identities/provider/discord.rb', line 19
def user_details_url
"https://discord.com/api/users/@me"
end
|