class Plangrade::OAuth2Client
Constants
- AUTHORIZE_PATH
- SITE_URL
- TOKEN_PATH
Public Class Methods
new(client_id, client_secret, opts={}) { |self| ... }
click to toggle source
Calls superclass method
# File lib/plangrade/oauth2_client.rb, line 10 def initialize(client_id, client_secret, opts={}) site_url = opts.delete(:site_url) || SITE_URL opts[:token_path] ||= TOKEN_PATH opts[:authorize_path] ||= AUTHORIZE_PATH super(site_url, client_id, client_secret, opts) yield self if block_given? self end
Public Instance Methods
exchange_auth_code_for_token(opts={})
click to toggle source
client_id={client_id}&code=G3Y6jU3a&grant_type=authorization_code& redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fplangrade%2Fcallback&client_secret={client_secret}
# File lib/plangrade/oauth2_client.rb, line 57 def exchange_auth_code_for_token(opts={}) unless (opts[:params] && opts[:params][:code]) raise ArgumentError.new("You must include an authorization code as a parameter") end opts[:authenticate] ||= :body code = opts[:params].delete(:code) authorization_code.get_token(code, opts) end
refresh!(token, opts={})
click to toggle source
client_id={client_id}&refresh_token=G3Y6jU3a&grant_type=refresh_token& client_secret={client_secret}
# File lib/plangrade/oauth2_client.rb, line 82 def refresh!(token, opts={}) opts[:authenticate] = :body refresh_token.get_token(token, opts) end