Sha256: a195f9847061676a8c3335d2e51989dbd55a5fb1834ca83d786cc900bf4fb582

Contents?: true

Size: 801 Bytes

Versions: 8

Compression:

Stored size: 801 Bytes

Contents

# frozen_string_literal: true
require 'osa/clients/http_client'
require 'faraday'
require 'osa/util/constants'

module OSA
  class MSAuthClient < HttpClient
    def initialize
      connection = Faraday.new(
        url: 'https://login.microsoft.com'
      )
      super connection
    end

    def code_token(code)
      body = {
        client_id: CLIENT_ID,
        scope: SCOPE,
        redirect_uri: REDIRECT_URL,
        grant_type: :authorization_code,
        code: code
      }
      post('/consumers/oauth2/v2.0/token', body, {})
    end

    def refresh_token(refresh_token)
      body = {
        client_id: CLIENT_ID,
        scope: SCOPE,
        refresh_token: refresh_token,
        grant_type: :refresh_token
      }
      post('/consumers/oauth2/v2.0/token', body)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
osa-0.2.3 lib/osa/clients/ms_auth_client.rb
osa-0.2.2 lib/osa/clients/ms_auth_client.rb
osa-0.2.1 lib/osa/clients/ms_auth_client.rb
osa-0.2.0 lib/osa/clients/ms_auth_client.rb
osa-0.1.3 lib/osa/clients/ms_auth_client.rb
osa-0.1.2 lib/osa/clients/ms_auth_client.rb
osa-0.1.1 lib/osa/clients/ms_auth_client.rb
osa-0.1.0 lib/osa/clients/ms_auth_client.rb