class PayPal::SDK::Core::OpenIDConnect::DataTypes::Tokeninfo

Constants

FP_PATH
PATH

Public Class Methods

authorize_url(options = {}) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 100
def authorize_url(options = {})
  OpenIDConnect.authorize_url(options)
end
basic_auth_header(options) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 62
def basic_auth_header(options)
  credentials = options[:client_id].to_s + ":" + options[:client_secret].to_s
  encoded = Base64.encode64(credentials.force_encoding('UTF-8')).gsub!(/\n/, "")
  "Basic #{encoded}"
end
create(options, http_header = {})
create_fp(options, http_header = {})
create_from_authorization_code(options, http_header = {}) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 68
def create_from_authorization_code(options, http_header = {})
  options = { :code => options } if options.is_a? String
  options = options.merge( :grant_type => "authorization_code" )
  Tokeninfo.new(api.post(PATH, with_credentials(options), http_header))
end
Also aliased as: create
create_from_future_payment_auth_code(options, http_header = {}) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 83
def create_from_future_payment_auth_code(options, http_header = {})
  options = { :code => options } if options.is_a? String
  options = options.merge( { :grant_type => "authorization_code", :response_type => "token", :redirect_uri => "urn:ietf:wg:oauth:2.0:oob" } )
  http_header = http_header.merge( { "Content-Type" => "application/x-www-form-urlencoded", "Authorization" => basic_auth_header(with_credentials(options)) } )
  Tokeninfo.new(api.post(FP_PATH, options, http_header))
end
Also aliased as: token_hash, create_fp
create_from_refresh_token(options, http_header = {}) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 75
def create_from_refresh_token(options, http_header = {})
  options = { :refresh_token => options } if options.is_a? String
  options = options.merge( :grant_type => "refresh_token" )
  http_header = http_header.merge( { "Content-Type" => "application/x-www-form-urlencoded", "Authorization" => basic_auth_header(with_credentials(options)) } )
  Tokeninfo.new(api.post(PATH, options, http_header))
end
Also aliased as: refresh
load_members() click to toggle source
# File lib/paypal-sdk/core/openid_connect/data_types.rb, line 47
def self.load_members
  object_of :scope, String
  object_of :access_token, String
  object_of :refresh_token, String
  object_of :token_type, String
  object_of :id_token, String
  object_of :expires_in, Integer
end
refresh(options, http_header = {})
token_hash(options, http_header = {})
with_credentials(options = {}) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 92
def with_credentials(options = {})
  options = options.dup
  [ :client_id, :client_secret ].each do |key|
    options[key] = self.send(key) unless options[key] or options[key.to_s]
  end
  options
end

Public Instance Methods

logout_url(options = {}) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 115
def logout_url(options = {})
  OpenIDConnect.logout_url({ :id_token => self.id_token }.merge(options))
end
refresh(options = {}) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 105
def refresh(options = {})
  tokeninfo = self.class.refresh({
    :refresh_token => self.refresh_token}.merge(options))
  self.merge!(tokeninfo.to_hash)
end
userinfo(options = {}) click to toggle source
# File lib/paypal-sdk/core/openid_connect.rb, line 111
def userinfo(options = {})
  Userinfo.get({ :access_token => self.access_token }.merge(options))
end