Hi, I am building a few systems using Yii2 and I would like the user to always log in from my main system. Let’s call it Portal.
So when a user wants access to another system he/she clicks on a link and will see a popup from the main system Portal. Write his/hers login details and will then be redirected back to the application on successful authentification. Just like Facebook and many more have.
No system except Portal will be having the passwords. I also need to pass extra parameters back containing what the user should be able to access on the system.
On the client side I am using Yii2 AuthClient
My problem is on the server side. I imagine that oauth2 is the best way to go and I have been looking at Filsh yii2-oauth2-server but I can not get it to work. And it is not very well documented. I always get this error:
<message>You are requesting with an invalid credential.</message>
I tried Filsh yii2-oauth2-server on a new installed Yii 2.0.1 but then I got this error instead:
<name>PHP Fatal Error</name>
Call to a member function getServer() on a non-object
Does anyone have any suggestion in direction on where I can look or if I should go with another protocol then oauth2 and then why.
Have anyone else tried to do something like this and just how did you do?
I’ve been trying and searching the whole day with very little success.
I don’t know about the plugins but when you first redirect to Portal, you should be passing a client id in the url. When Portal redirects back to your site, your site will then make another 2 calls to Portal using a POST (and usually to a web service), I am guessing it is the first of these that is failing. The first call is to get an access token and requires that either the client id and secret are passed using an HTTP authorization header or otherwise in the body of the POST (depending on what Portal allows/accepts). The second of these calls swaps the token for the user information and should not require client id or secret.
If you have not set up the client id and secret in the config settings (or not set them correctly - watch out for whitespace and stuff) then I would suspect this to be the most likely cause of your error.