0
votes

Having trouble implementing Onelogin/Openid in a simple PHP example. Not sure which API is the correct one to start with. I cannot use any libraries in my code as the destination environment will not allow it, but it will allow PHP/HTML.

We intend to use the Authentication Flow part of the OIDC overview https://developers.onelogin.com/openid-connect. But this overview does not indicate which API reference to start with. I had assumed https://developers.onelogin.com/openid-connect/api/authorization-code which i am able to log into Onelogin without issue but it is not passing back the validated user details so we can confirm them on our system. We have included a valid https callback url in the Configureation of the Openid Connect App and the Login url but these are not triggered by our calls so far.

We are using Grant type "The Authentication (or Basic) Flow is designed for apps that have a back end that can communicate with the IdP away from prying eyes." So we have a backend server to deal with secure authentication.

If https://developers.onelogin.com/openid-connect/api/authorization-code is not the correct starting API call then can someone advise which would be the correct call.

Edited to Update: Cracked it. My mistake was not sending the user to the URL. I was treating it like an API call only on the server, when i should have been directing the user to that URL. Re-read the doc and it does say that. Easily missed.

1

1 Answers

0
votes

Appreciate it can look complex, but once you get started it starts to fall into place. Best thing to do is to download the Postman templates or use the new Onelogin OIDC inspector tool as these will pre-build the relevant endpoints for you.

The Inspector is here: https://developers.onelogin.com/openid-connect/inspector

But for reference, the endpoint to kick off the Authorization flow ( and other flows ) looks like this:

https://{{OIDC_url}}.onelogin.com/oidc/auth?client_id={{OIDC_client_id}}&nonce={{$guid}}&redirect_uri={{OIDC_redirect_uri}}&response_type=code&scope=openid&state=

The vendor documentation for this endpoint is her: https://developers.onelogin.com/openid-connect/api/authorization-code

Let me know how you get on