= OAuth Decidim is both an OAuth client (via https://github.com/omniauth/omniauth[omniauth]) and an OAuth provider (via https://github.com/doorkeeper-gem/doorkeeper[doorkeeper]). Check the xref:services:social_providers.adoc[Social Providers] document to check the provider and client configurations. == Performing more actions on omniauth registration Some times, there is the need to perform more actions than just creating a user on registration, this is why `CreateOmniauthRegistration` command publishes a `"decidim.user.omniauth_registration` event after registration so that developers can subscribe to it and perform other actions like user verification or alike. This event comes with the following payload: * user_id: The id for the registered User. * identity_id: The id for the social Identity. * provider: The name for the social provider. * uid: OAuth's uid * email: User's email. * name: User's name. * nickname: User's nickname after being normalized. * avatar_url: Avatar's url, if any. * raw_data: The raw hash received directly from the Omniauth gem. To be notified after a registration one should subscribe to the event, in the passed block the after registration code should be implemented: [source,ruby] ---- ActiveSupport::Notifications.subscribe "decidim.user.omniauth_registration" do |name, started, finished, unique_id, data| puts "the data: #{data.inspect}" IdCatMobilVerificationJob.perform_later(data[:raw_data]) end ---- Note that, if the user is already registered, the `CreateOmniauthRegistration` command will not trigger the "decidim.user.omniauth_registration" event by instead it will trigger the "decidim.user.omniauth_login" event, which has the same payload as the registration event. For instance, to retrigger the `IdCatMobilVerificationJob` after a user logs in via omniauth, you can subscribe to the "decidim.user.omniauth_login" event as follows: [source,ruby] ---- ActiveSupport::Notifications.subscribe "decidim.user.omniauth_login" do |name, started, finished, unique_id, data| puts "the data: #{data.inspect}" IdCatMobilVerificationJob.perform_later(data[:raw_data]) end ---- It is a good practice to delegate the required implementation to a Job to bring a fastest response to the user, also it will avoid that crashes in this code to propagate to the registration process.