2015-10-06 11:21:20 +02:00
|
|
|
class FranceConnectService
|
2018-01-11 15:29:58 +01:00
|
|
|
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)
|
2018-01-11 11:07:25 +01:00
|
|
|
client = FranceConnectParticulierClient.new(code)
|
2015-12-24 10:12:23 +01:00
|
|
|
|
|
|
|
access_token = client.access_token!(client_auth_method: :secret)
|
2018-01-11 17:07:35 +01:00
|
|
|
|
2015-12-24 10:12:23 +01:00
|
|
|
user_info = access_token.userinfo!
|
2018-01-11 17:07:35 +01:00
|
|
|
hash = Hashie::Mash.new(user_info.raw_attributes)
|
2015-12-24 10:12:23 +01:00
|
|
|
|
|
|
|
hash.france_connect_particulier_id = hash.sub
|
|
|
|
hash
|
|
|
|
end
|
2015-10-06 11:21:20 +02:00
|
|
|
end
|