Sha256: 5f95c57bf48f9f218ed65adb2a55972305991af42d2f218827aeb2c71b39eb17
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
require 'omniauth/strategies/oauth2' MAIN_DOMAIN = Rails.env.development? ? 'http://8protons.dev' : 'https://8protons.com' API_DOMAIN = Rails.env.development? ? 'http://api8p.com' : 'https://api8p.com' module OmniAuth module Strategies # Authentication strategy for connecting with APIs constructed using # the [OAuth 2.0 Specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-10). # You must generally register your application with the provider and # utilize an application id and secret in order to authenticate using # OAuth 2.0. class Protons < OmniAuth::Strategies::OAuth2 # change the class name and the :name option to match your application name option :name, :protons option :client_options, { site: MAIN_DOMAIN, token_url: "#{API_DOMAIN}/oauth2/tokens", #authorize_url: '/oauth/auth' } uid { raw_info['id'] } info do { name: raw_info['fields']['display_name'], email: raw_info['fields']['email'], nickname: raw_info['fields']['username'] #:gravatar_hash => raw_info['fields']['gravatar_hash'] # and anything else you want to return to your API consumers } end extra do { 'raw_info' => raw_info } end def raw_info @raw_info ||= access_token.get("#{API_DOMAIN}/base/me").parsed end end # Protons end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omniauth-protons-0.4 | lib/omniauth/strategies/protons.rb |