Module: Authkeeper::DiscordAuthApi::Requests::FetchAccessToken

Included in:
Client
Defined in:
app/lib/authkeeper/discord_auth_api/requests/fetch_access_token.rb

Instance Method Summary collapse

Instance Method Details

#fetch_access_token(client_id:, client_secret:, code:, redirect_uri:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/lib/authkeeper/discord_auth_api/requests/fetch_access_token.rb', line 7

def fetch_access_token(client_id:, client_secret:, code:, redirect_uri:)
  form_post(
    path: 'oauth2/token',
    body: {
      grant_type: 'authorization_code',
      code: code,
      redirect_uri: redirect_uri,
      client_id: client_id,
      client_secret: client_secret
    },
    headers: {
      'Content-Type' => 'application/x-www-form-urlencoded'
    }
  )
end