Sha256: 2a20a5ad3b06dd6646cfd01db49617ab3567db7ef125b8908fdf6d3aff39f40b

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'omniauth-oauth2'

module OmniAuth
    module Strategies
        class Dataporten < OmniAuth::Strategies::OAuth2
            option :name, "dataporten"

            option :client_options, {
                    site: "https://auth.dataporten.no",
                    authorize_url: "/oauth/authorization",
                    token_url: "/oauth/token"
            }

            option :redirect_url

            uid { raw_info['user']['userid'] }

            info do
                {
                    name:           raw_info['user']['name'],
                    username:       raw_info['user']['userid'],
                    email:          raw_info['user']['email'],
                    image:          "https://api.dataporten.no/userinfo/v1/user/media/" + raw_info['user']['profilepicture']
                }
            end

            extra do
                { raw_info: raw_info }
            end

            def raw_info
                @raw_info ||= access_token.get('/userinfo').parsed
            end

            private

            def callback_url
                options[:redirect_url] + script_name + callback_path
            end

            #def request_phase
            #       options[:response_type] ||= 'code'
	        #       super   
            #end
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-dataporten-0.0.8 lib/omniauth/strategies/dataporten.rb