class Rack::OAuth2::Server::Token::Request

Public Class Methods

new(env) click to toggle source
# File lib/rack/oauth2/server/token.rb, line 49
def initialize(env)
  auth = Rack::Auth::Basic::Request.new(env)
  if auth.provided? && auth.basic?
    @client_id, @client_secret = auth.credentials.map do |cred|
      Util.www_form_url_decode cred
    end
    super
  else
    super
    @client_secret = params['client_secret']
    @client_assertion = params['client_assertion']
    @client_assertion_type = params['client_assertion_type']
    if client_assertion.present? && client_assertion_type == URN::ClientAssertionType::JWT_BEARER
      require 'json/jwt'
      @client_id = JSON::JWT.decode(
        client_assertion,
        :skip_verification
      )[:sub] rescue nil
    end
  end
  @grant_type = params['grant_type'].to_s
end