# frozen_string_literal: true require "omniauth-oauth" require "json" module OmniAuth module Strategies class Pbs < OmniAuth::Strategies::OAuth option :name, "pbs" option :callback_url, "/oauth/callback" option :client_options, { site: "https://usosapps.pbs.edu.pl", request_token_url: "/services/oauth/request_token?scopes=email", authorize_url: "https://usosapps.pbs.edu.pl/services/oauth/authorize", access_token_url: "/services/oauth/access_token" } uid { raw_info["id"] } info do { email: raw_info["email"], first_name: raw_info["first_name"], last_name: raw_info["last_name"] } end extra do skip_info? ? {} : { raw_info: raw_info } end def raw_info @raw_info ||= JSON.parse(access_token.get("/services/users/user?fields=id|first_name|last_name|email").body) end end end end