General developer forum

How to expose a callback URL to a third-party service in a custom auth plugin?

 
Picture of wz z
How to expose a callback URL to a third-party service in a custom auth plugin?
 

I need to implement a custom auth plugin for Wechat integration, the official documentation is here. My pseudo code and logic is as below:


Step 1:

// the Wechat browser has some special ability to interact with the Wechat server

if ( an anonymous user access a Moodle authenticated-user-only page in the Wechat browser)  {

  header("https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect");

  /* note: In the above URL, there is a redirect_uri query parameter, which must be a third-party accessible URL in Moodle. Open.weixin.qq.com server process the above request and then append a CODE parameter to the redirect_uri and request the redirect_uri URL.

}


Step 2: 

There should be a function or something else to process the Open.weixin.qq.com-initiated redirect_uri request, read the CODE paramer, and construct another http request to open.weixin.qq.com to get the final data (the Wechat user openid),  then query a database  table to find the correspondent Moodle username, and programatically login in that user, of course, if necessary, redirect user to the Moodle authenticated-user-only page .


I don't know in which function or hook to make this. Or even instead of an auth plugin, need I write another type of plugin?

 
Average of ratings: -
Picture of wz z
Re: How to expose a callback URL to a third-party service in a custom auth plugin?
 

Finally, I found that exposing a public accessible path is really simple, just creating a file. Thank you all the same!

 
Average of ratings: -