I had a custom application login and I want to perform login to Moodle using that login.
I have set up wso2 identity server and created a service provider for moodle which is configured properly with moodle.
In moodle also I have setup OAuth Plugin and created fields respectively. Login is working fine if I do it as a custom oauth button on login page in moodle
If I try to recreate a similar auth flow inside the custom login page with Oauth2 and credentials of wso2 service provider configured in WSO2
I am getting into lots of issues
With wso2 I am getting user auth token from wso2 I am able to retrieve moodle redirect URL :
Initially, when I redirect to this URL it gave an error state not found so after a long search I added state parameter in redirected url
The new redirection URL is below
http://x.x.x.x/moodle/admin/oauth2callback.php?code={{auth_code}}&state=%2Fauth%2Foauth2%2Flogin.php%3Fwantsurl%3Dhttp%253A%252F%252Fxx.xx.xx.xx%252Fmoodle%252F&session_state={{session_state}}
Now as I redirect to this URL it is showing
Your session has most likely timed out. Please log in again.
I try it from moodle trying to log in from moodle home page using the wso2 auth button it is working
I am not able to figure out if I am missing configuration or anything else
For setting up moodle and oath I took help from the below blog
Please help