How to insert Social Login in a certain page?


I want to use Social Login not only in the standard login page, but somewhere else. How can I do this?

Thanks a lot!

Best Answer

  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    Answer ✓
    Hi Sven,

    it unfortunately seems like we haven't added the blocks in Drupal 8 yet.
    Could you please psot a link to your website?

    I will then have a closer look and give you the JavaScript code that you can copy/paste in order to add the buttons.


  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited May 2017
    Hi Sven,

    please have a look at the Structure \ Blocks in your Drupal admin area.
    There you should also see a social login block that you can move at the position of your choosing.

  • Hi Claude,

    unfortunately there isn't a block like this. I'm using Drupal 8. Maybe it isn't implemented there already?
  • Hi Claude,

    yesterday I found the solution. I had to add the "@Block" part to the SocialLoginBlock.php:

    * Displays a Social Login block.
    * @Block(
    * id = "SocialLoginBlock",
    * admin_label = @Translation("Social Login block"),
    * )

    After this the block showed up.

    But I experienced another problem with the SocialLoginBlockForm.php afterwards. There was an error message about a class which could not be found and line 40 was mentioned: $is_https = Drupal::request()->isSecure();
    Maybe not a good workaround, but changing it to $is_https = true solved it for now.
    I couldn't have a closer look already...

  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited May 2017
    Hi Sven,

    thank you very much for the update and the bugfix!
    It seems like we unintentionally removed that comment during one of the last commits.

    To fix the error with
    $is_https = Drupal::request()->isSecure();

    you can also add the following line at the top of the file SocialLoginBlock.php:
    use Symfony\Component\HttpFoundation\Request;

    We will push a new version with the bugfix.
  • Hi Claude,

    I just tried what mentioned (adding the "use..." line of code at the top). Unfortunately it didn't work.
    Here's the error message I get:
    Error: Class 'Drupal\social_login\Form\Drupal' not found in Drupal\social_login\Form\SocialLoginBlockForm->buildForm() (line 41 of modules/social_login/src/Form/SocialLoginBlockForm.php)


Please sign in to your OneAll account to ask a new question or to contribute to the discussions.

Please click on the link below to connect to the forum with your OneAll account.