Sha256: 3b133668935f0039995eec9975d07c8659f14f8ad4184eb2031330563b2dfefd
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'omniauth-oauth2' module OmniAuth module Strategies class Stagebloc < OmniAuth::Strategies::OAuth2 option :name, 'stagebloc' option :client_options, { site: 'https://api.stagebloc.com/v1', authorize_url: 'https://stagebloc.com/connect', token_url: 'https://api.stagebloc.com/v1/oauth2/token' } option :access_token_options, { header_format: 'OAuth %s' } uid { raw_info['id'] } info do { 'email' => raw_info['email'] } end extra do { 'raw_info' => raw_info } end def raw_info @raw_info ||= access_token.get('users/me').parsed end def build_access_token super.tap do |token| token.options.merge!(access_token_options) end end def access_token_options options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h } end end end end OAuth2::Response.register_parser(:stagebloc_parser, 'application/json') do |body| parsed = MultiJson.respond_to?(:adapter) ? MultiJson.load(body) : MultiJson.decode(body) rescue body parsed['data'] end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omniauth-stagebloc-0.0.1 | lib/omniauth/strategies/stagebloc.rb |