Sha256: 759edca989be36d933da18098e30d24eeabfea6bec8994c1d0f674cfcbd631d5

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 Bytes

Contents

require 'omniauth'
require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class Openstax < OAuth2
      option :name, "openstax"

      option :client_options, {
        :site => OpenStax::Connect.configuration.openstax_services_url,
        :authorize_url => "/oauth/authorize"
      }

      uid        { raw_info["id"] }

      info do
        {
          username: raw_info["username"],
          first_name: raw_info["first_name"],
          last_name: raw_info["last_name"]
          # and anything else you want to return to your API consumers
        }
      end

      def raw_info
        @raw_info ||= access_token.get('/api/users/me.json').parsed
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openstax_connect-0.0.10 lib/omniauth/strategies/openstax.rb
openstax_connect-0.0.9 lib/omniauth/strategies/openstax.rb