Sha256: 4ad428409a5cc0865ff97e72f62d5d6e30aef5047334db70a3760519427c2d1c
Contents?: true
Size: 1 KB
Versions: 13
Compression:
Stored size: 1 KB
Contents
module OpenIDConnect class AccessToken < Rack::OAuth2::AccessToken::Bearer attr_required :client attr_optional :id_token def initialize(attributes = {}) super @token_type = :bearer end def user_info!(scheme = :openid) hash = resource_request do get client.user_info_uri end ResponseObject::UserInfo::OpenID.new hash end def id_token! client.check_id_uri hash = resource_request do get client.check_id_uri end ResponseObject::IdToken.new hash end private def resource_request res = yield case res.status when 200 JSON.parse(res.body).with_indifferent_access when 400 raise BadRequest.new('API Access Faild', res) when 401 raise Unauthorized.new('Access Token Invalid or Expired', res) when 403 raise Forbidden.new('Insufficient Scope', res) else raise HttpError.new(res.status, 'Unknown HttpError', res) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems