Setup Guide to Configure Keycloak with Drupal

Step 1: Follow the step by step guide to configure Keycloak with Drupal

  • First of all, Download Keycloak and install it.
  • Start Server: Start the keycloak server by running the _standalone.sh_ file

    Root Directory of keycloak/bin/standalone.sh

  • Add Realm: Now login to keycloak administration console and navigate to your desired realm. You can add new realm by selecting Add Realm option.
  • Keycloak add realm
  • Create Realm: Enter Realm Name and click on CREATE to add realm.
  • Create Role: The Role will be used by your applications to define which users will be authorized to access the application. Click on the Roles and choose Add Role.
  • Add Role
  • Add User: We need to add users to realm who will be able to access the resources of realm. Click on the Users and choose to Add a new User.
  • Add User
  • User Configuration: After user is created following action needs to be performed on it.
    • Setting a password for it so click on Credentials and set a new Password for the user.
    • Credentials

      NOTE : Disabling Temporary will make user password permanent


  • Map User: We need to map user to a role. Click on Role Mappings and assign the user desired role from available roles and clicking on add selected.
  • Role Mapping
  • Create groups: Click on the Groups and choose New to create a new group.
  • Create Group
  • Assign user to group: Select the user whom you want to add in group. Choose Groups option from tab and then select the group-name and click on join.
  • Assign User to Group
  • Create OpenID client: Click on the Clients and choose create to create a new client. Enter client id and select client protocol openeid-connect and select Save.
  • Create Openid Connect
  • Enter Change Access Type: Afterclient is created change it's access type to confidential
  • Change Access Type
  • Enter Valid Redirect URLs: Copy callback URL from module and then click on SAVE.
    Ex -- https://oauth/callback
  • Keycloak Group Mapper: Now to get group details we need to perform its client mapping with group membership else group details will not be fetched. So in client select Mappers and then click on create. Select mapper type Group Membership and enter name and token claim-name i.e the attribute name corresponding which groups will be fetched and click on Save Keycloak Group Mapper

    Note: -- If full path is on group path will be fetched else group name will be fetched.



  • Get Client Secret: Now we need to get client secret. So select Clients and select credentials and copy your secret from here.
  • Client Credentials
  • You have successfully completed your Keycloak OAuth Server side configurations

Step 2: Configure miniOrange Drupal Oauth Client module.

  • Login in your Drupal site’s admin console and click on Extend/Module from the top navigation bar.
  • Select the Install new module option to install a new module on your Drupal site.
  • Install New Module
  • Upload the downloaded zip file of the Module and click on the Install button to continue.
  • Click on Extend/Modules from the top navigation bar again and scroll down till you find miniOrange OAuth Client. Click on the checkbox next to it and click on the Install button to enable the module.
  • Miniorange OAuth install
  • Now click on Configuration in Drupal dashboard then click on Drupal OAuth Client Configuration.
  • Drupal OAuth Configuration
  • In Configure OAuth Application:

    1. Select application from dropdown list.
    2. Copy the CallBack/Redirect URL and save it on your OAuth Provider.
    3. Fill in the following details:

      1. Custom app name
      2. Display Name
      3. Client ID which is application ID from Step 1.
      4. Client Secret which is key value from step 1.
      5. Scope
      6. Authorize Endpoint
      7. Access Token Endpoint
      8. Get User Info Endpoint
    4. Then click on save configuration
    5. Now click on the Test Configuration button. This Test Configuration link will give you the list of the attributes that are coming from your OAuth Provider.
  • Copy the email and the name attributes and save them under the Attribute & Role Mapping tab in the Email Attribute and Name Attribute text field respectively.
    Please note: This step is mandatory for your login to work. Click on the Save Configuration button to save your attribute configurations.
  • Save Configuration
  • Now logout and go to your Drupal 8 site’s login page, you will automatically find a Login with there. If you want to add your login link to other pages as well, please follow the steps given in the below image:
  • Instructions to add login link to different pages
  • If you want to check out our complete list of features and our various licensing plans, you can go to the Upgrade Plans tab in the module.
  • Congratulations, you have successfully configured the miniOrange Drupal OAuth Client module.
    Scope: email profile
    Authorize EndPoint: <Keycloak base URL>/realms/{realm-name}/protocol/openid-connect/auth
    Access Token Endpoint: <Keycloak base URL>/realms/{realm-name}/protocol/openid-connect/token
    Get User Info Endpoint: <Keycloak base URL>/realms/{realm-name}/protocol/openid-connect/userinfo

Free Trial

If you are looking for anything which you cannot find, please drop us an email on info@xecurify.com