module Typetalk::Api::Auth
Attributes
Public Class Methods
Public Instance Methods
get_access_token(options={})
click to toggle source
# File lib/typetalk/api/auth.rb, line 7 def get_access_token(options={}) options = {client_id:nil, client_secret:nil, grant_type:nil, scope:nil, code:nil, redirect_uri:nil}.merge(options) body = { client_id: options[:client_id] || Typetalk.config.client_id, client_secret: options[:client_secret] || Typetalk.config.client_secret, grant_type: options[:grant_type] || Typetalk.config.grant_type, scope: options[:scope] || Typetalk.config.scope, } if body[:grant_type] == 'authorization_code' body[:code] = options[:code] || @authorization_code body[:redirect_uri] = options[:redirect_uri] || Typetalk.config.redirect_uri end response = connection.post do |req| req.url 'https://typetalk.com/oauth2/access_token' req.body = body end parse_response(response) end
update_access_token(refresh_token, options={})
click to toggle source
# File lib/typetalk/api/auth.rb, line 30 def update_access_token(refresh_token, options={}) options = {client_id:nil, client_secret:nil}.merge(options) body = { client_id: options[:client_id] || Typetalk.config.client_id, client_secret: options[:client_secret] || Typetalk.config.client_secret, grant_type: 'refresh_token', refresh_token: refresh_token } response = connection.post do |req| req.url 'https://typetalk.com/oauth2/access_token' req.body = body end parse_response(response) end