Class: AccessToken

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Oauth2Token
Defined in:
app/models/access_token.rb

Instance Method Summary collapse

Methods included from Oauth2Token

#expired!, #expires_in, included

Instance Method Details

#to_bearer_token(with_refresh_token = false) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/access_token.rb', line 8

def to_bearer_token(with_refresh_token = false)
  bearer_token = Rack::OAuth2::AccessToken::Bearer.new(
    :access_token => self.token,
    :expires_in => self.expires_in
  )
  if with_refresh_token
    bearer_token.refresh_token = self.create_refresh_token(
      :user => self.user,
      :client => self.client
    ).token
  end
  p bearer_token.token_response
  bearer_token
end