Method: Dnsimple::Client::Oauth#exchange_authorization_for_token
- Defined in:
- lib/dnsimple/client/oauth.rb
#exchange_authorization_for_token(code, client_id, client_secret, options = {}) ⇒ String
Exchange the short-lived authorization code for an access token you can use to authenticate your API calls.
16 17 18 19 20 21 22 |
# File 'lib/dnsimple/client/oauth.rb', line 16 def (code, client_id, client_secret, = {}) attributes = { code: code, client_id: client_id, client_secret: client_secret, grant_type: "authorization_code" } attributes[:state] = .delete(:state) if .key?(:state) attributes[:redirect_uri] = .delete(:redirect_uri) if .key?(:redirect_uri) response = client.post(Client.versioned("/oauth/access_token"), attributes, ) Struct::OauthToken.new(response) end |