Sha256: 6d9da02b2f35f0711c90e76ac54fc56b131a70ede8752d75199ccefa77d67f72
Contents?: true
Size: 731 Bytes
Versions: 1
Compression:
Stored size: 731 Bytes
Contents
require 'net/http' module AzureAuthRequestHelper def user_info host = 'https://graph.microsoft.com/oidc/userinfo' url = URI.parse(host) req = Net::HTTP::Post.new(url.to_s) req['Authorization'] = "Bearer #{params[:access_token]}" response = Net::HTTP.start(url.host, url.port, use_ssl: true) do |http| http.request(req) end @user_info = case response.code when '400' [ :error, JSON.parse(response.body.to_str) ] when '200' [ :success, JSON.parse(response.body.to_str) ] else [:error, "Invalid response #{response.body.to_str} received."] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omniauth-azure-oauth2-v2-0.1.2 | lib/omniauth/azure_auth_request_helper.rb |