Class: TeambitionApi::Helpers::Oauth
- Inherits:
-
Object
- Object
- TeambitionApi::Helpers::Oauth
- Extended by:
- Base
- Defined in:
- lib/teambition_api/helpers/oauth.rb
Constant Summary collapse
- ACTIONS_HASH =
{ authorize: "/oauth2/authorize", access_token: "/oauth2/access_token" }
Class Method Summary collapse
Methods included from Base
Class Method Details
.authorize_url(callback_url, state) ⇒ Object
12 13 14 15 |
# File 'lib/teambition_api/helpers/oauth.rb', line 12 def self.(callback_url, state) server_url = "#{TeambitionApi.config.oauth_server}#{ACTIONS_HASH[:authorize]}?client_id=#{TeambitionApi.config.client_key}&redirect_uri=#{callback_url}&state=#{state}" return server_url end |
.get_access_token(code) ⇒ Object
17 18 19 20 21 |
# File 'lib/teambition_api/helpers/oauth.rb', line 17 def self.get_access_token(code) params = { client_id: TeambitionApi.config.client_key, client_secret: TeambitionApi.config.client_secret, code: code } result = post(ACTIONS_HASH[:access_token], params, TeambitionApi.config.oauth_server) return result["access_token"] end |