Adding OAuth2 issuer buttons to alt login page?

Adding OAuth2 issuer buttons to alt login page?

by Dan Jackson -
Number of replies: 1

I've set up OAuth2 login with Microsoft as the issuer on our test Moodle site.

We use an alt login page, as we want users to be logging in via federated ID systems such as Shibboleth or Azure AD instead of trying to use the standard Moodle username and password box.

However, while I can see the nice Microsoft issuer button on the standard login page, I can't figure out what code I need to put on the alt page to correctly generate this?

I tried copying and pasting the HTML but this results in an expired sesskey error.

I need to know what the proper Moodle PHP code is to show this button. I've tried looking through the Moodle PHP files to see if I can find it but not having much luck.

Can anyone help?

We're on Moodle 3.5 if that makes a difference.

Here's a picture of the button I mean:

Attachment 2020-02-05_15-58-05.png
Average of ratings: -
In reply to Dan Jackson

Re: Adding OAuth2 issuer buttons to alt login page?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi,

No experience with that button specifically and this isn't really the perfect Moodle way to do it, but for a quick hack to get rid of the session key error, find the bit of HTML where the session key is (random alphanumeric string) and replace this with a call to the Moodle sesskey() function - you'll need to have included config.php on your alt login page, and it obviously has to be hosted on the same Moodle server. If
you're lucky this might be all you need to make it work.

--sam