Class: EpitechApi::OfficeProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/epitech_api/Providers/office_provider.rb

Class Method Summary collapse

Class Method Details

.login(code) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
# File 'lib/epitech_api/Providers/office_provider.rb', line 9

def self.(code)
  uri = URI("https://intra.epitech.eu/auth/office365?code=#{code}&state=%2f")
  response = Net::HTTP.get_response(uri)
  raise InvalidCredentials unless response.code.to_i == 302

  cookie = CGI::Cookie::parse(response['Set-Cookie'])
  token = cookie['user']
  User.new token
end