Sha256: 83ad73892e55cbda1c1830a2fce0ef14229f55009881da02a1999a00557b0cb1
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
require 'omniauth-oauth2' module OmniAuth module Strategies class DrChrono < OmniAuth::Strategies::OAuth2 option :name, 'drchrono' option :client_options, { :site => 'https://drchrono.com/api', :authorize_url => 'https://drchrono.com/o/authorize', :token_url => 'https://drchrono.com/o/token/' } option :scope, 'user:read' uid do raw_info['id'] end info do { 'auth' => oauth2_access_token, 'doctor' => doctor, 'offices' => offices } end extra do { 'raw_info' => raw_info } end def callback_url full_host + script_name + callback_path end alias :oauth2_access_token :access_token def access_token ::OAuth2::AccessToken.new(client, oauth2_access_token.token, { :expires_in => oauth2_access_token.expires_in, :expires_at => oauth2_access_token.expires_at }) end def raw_info @raw_info ||= access_token.get(profile_endpoint).parsed end def doctor @doctor ||= access_token.get(doctors_endpoint).parsed end def offices @offices ||= access_token.get(offices_endpoint).parsed['results'] end private def profile_endpoint '/users/current' end def doctors_endpoint "/doctors/#{raw_info['doctor']}" end def offices_endpoint '/offices' end end end end OmniAuth.config.add_camelization 'drchrono', 'DrChrono'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
omniauth-drchrono-oauth2-1.1.0 | lib/omniauth/strategies/drchrono.rb |
omniauth-drchrono-oauth2-1.0.0 | lib/omniauth/strategies/drchrono.rb |