Sha256: f520c53a83f4f91a5ffea96cae2ce8b4b1fa0fb9ade12653eac609d045cbccd8

Contents?: true

Size: 732 Bytes

Versions: 25

Compression:

Stored size: 732 Bytes

Contents

class Oauth2Token::AccessToken < Oauth2Token
  self.default_lifetime = 15.minutes

  belongs_to :refresh_token,
             class_name: "Oauth2Token::RefreshToken"

  def to_bearer_token(with_refresh_token = false)
    bearer_token = Rack::OAuth2::AccessToken::Bearer.new(
      access_token: token,
      expires_in:   expires_in
    )

    if with_refresh_token
      bearer_token.refresh_token = create_refresh_token!(
        user: user,
        client: client
      ).token
    end

    bearer_token
  end

  def setup
    super

    if refresh_token
      self.user       = refresh_token.user
      self.client     = refresh_token.client
      self.expires_at = [ expires_at, refresh_token.expires_at ].min
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
social_stream-2.2.2 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.2.2 app/models/oauth2_token/access_token.rb
social_stream-2.2.1 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.2.1 app/models/oauth2_token/access_token.rb
social_stream-2.2.0 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.2.0 app/models/oauth2_token/access_token.rb
social_stream-2.1.1 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.1.1 app/models/oauth2_token/access_token.rb
social_stream-2.1.0 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.1.0 app/models/oauth2_token/access_token.rb
social_stream-2.0.4 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.0.3 app/models/oauth2_token/access_token.rb
social_stream-2.0.3 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.0.2 app/models/oauth2_token/access_token.rb
social_stream-2.0.2 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.0.1 app/models/oauth2_token/access_token.rb
social_stream-2.0.1 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-2.0.0 oauth2_server/app/models/oauth2_token/access_token.rb
social_stream-oauth2_server-2.0.0 app/models/oauth2_token/access_token.rb
social_stream-2.0.0.beta3 oauth2_server/app/models/oauth2_token/access_token.rb