]> git.openstreetmap.org Git - rails.git/blob - app/models/oauth2_token.rb
Allow an optional comment to be given when closing a note
[rails.git] / app / models / oauth2_token.rb
1 class Oauth2Token < AccessToken
2   attr_accessor :state
3
4   def as_json(options={})
5     d = {:access_token=>token, :token_type => 'bearer'}
6     d[:expires_in] = expires_in if expires_at
7     d
8   end
9
10   def to_query
11     q = "access_token=#{token}&token_type=bearer"
12     q << "&state=#{URI.escape(state)}" if @state
13     q << "&expires_in=#{expires_in}" if expires_at
14     q << "&scope=#{URI.escape(scope)}" if scope
15     q
16   end
17
18   def expires_in
19     expires_at.to_i - Time.now.to_i
20   end
21 end