module Teambition
Top-level namespace
Constants
- API_DOMAIN
API
domain- AUTH_DOMAIN
Authorization domain
- VERSION
Current version number
Attributes
callback_url[RW]
@return [String] callback url
client_key[RW]
@return [String] client key provided by Teambition
client_secret[RW]
@return [String] client secret provided by Teambition
Public Class Methods
get_access_token(code)
click to toggle source
Fetch the access token by a code @param code [String] @return [String]
# File lib/teambition.rb, line 41 def get_access_token(code) res = Net::HTTP.post_form( URI.join(AUTH_DOMAIN, '/oauth2/access_token'), client_id: client_key, client_secret: client_secret, code: code ) JSON.parse(res.body)['access_token'] end
valid_access_token?(token)
click to toggle source
Validate the token @param token [String]
# File lib/teambition.rb, line 53 def valid_access_token?(token) uri = URI.join(API_DOMAIN, "/api/applications/#{client_key}/tokens/check") req = Net::HTTP::Get.new(uri) req['Authorization'] = "OAuth2 #{token}" res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |https| https.request(req) end res.code == '200' end