demarches-normaliennes/app/services/france_connect_service.rb

23 lines
589 B
Ruby
Raw Normal View History

class FranceConnectService
def self.authorization_uri
client = FranceConnectParticulierClient.new
client.authorization_uri(
scope: [:profile, :email],
state: SecureRandom.hex(16),
nonce: SecureRandom.hex(16))
end
2018-01-11 17:07:35 +01:00
def self.retrieve_user_informations_particulier(code)
client = FranceConnectParticulierClient.new(code)
access_token = client.access_token!(client_auth_method: :secret)
2018-01-11 17:07:35 +01:00
user_info = access_token.userinfo!
2018-01-11 17:07:35 +01:00
hash = Hashie::Mash.new(user_info.raw_attributes)
hash.france_connect_particulier_id = hash.sub
hash
end
end