How to authenticate logged-in user in Moodle using ASP.NET Core MVC?

32 Views Asked by At

I want to create ASP.NET Core MVC app as Moodle external tool. I created tokens for web services. I know that for Moodle web service is necessary to pass token and web service function name.

My question is how to know which user is logged-in in Moodle, and how to get his token or username/password and pass it to Moodle external tool? To get token, I must know username/password, and inversely.

1

There are 1 best solutions below

0
Russell England On

You want a Moodle user to access your external tool?

If the tool is already added to Moodle web services

And the user has the moodle/webservice:createtoken capability

The user can then get their token/security key by clicking on their user name (usually on the top right)

Then from the drop down menu, go to Preferences > User account > Security keys

And choose the key for your web service

https://docs.moodle.org/403/en/Security_keys