Class: MailChimp3::OAuth
- Inherits:
-
Object
- Object
- MailChimp3::OAuth
- Defined in:
- lib/mailchimp3/oauth.rb
Instance Method Summary collapse
- #authorize_url(redirect_uri:, state: nil) ⇒ Object
- #complete_auth(code, redirect_uri:) ⇒ Object
-
#initialize ⇒ OAuth
constructor
A new instance of OAuth.
Constructor Details
#initialize ⇒ OAuth
Returns a new instance of OAuth.
6 7 8 9 10 11 12 13 14 |
# File 'lib/mailchimp3/oauth.rb', line 6 def initialize @oauth = OAuth2::Client.new( MailChimp3.config.client_id, MailChimp3.config.client_secret, site: 'https://login.mailchimp.com', authorize_url: '/oauth2/authorize', token_url: '/oauth2/token' ) end |
Instance Method Details
#authorize_url(redirect_uri:, state: nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/mailchimp3/oauth.rb', line 16 def (redirect_uri:, state: nil) params = { redirect_uri: redirect_uri, state: state, }.compact @oauth.auth_code.(params) end |
#complete_auth(code, redirect_uri:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mailchimp3/oauth.rb', line 25 def complete_auth(code, redirect_uri:) token = @oauth.auth_code.get_token( code, redirect_uri: redirect_uri ) { token: token, token_string: token.token, metadata: (token) } end |