Method: CodePicnic::Token#initialize
- Defined in:
- lib/codepicnic/token.rb
#initialize(client_id, client_secret) ⇒ Token
Returns a new instance of Token.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/codepicnic/token.rb', line 12 def initialize(client_id, client_secret) response = RestClient.post Token.api_url, { grant_type: "client_credentials", client_id: client_id, client_secret: client_secret } parsed_response = JSON.parse(response) @access_token = parsed_response["access_token"] @created_at = parsed_response["created_at"].to_i @expires_in = parsed_response["expires_in"].to_i end |