Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Mobile Open Auth

From MoodleDocs

Use case

  1. the user launch the APP
  2. the user goes to settings
  3. the user add a site
  4. the user enter site url, website consumer key and website consumer secret
  5. the user is redirected to Moodle login page (an inside browser)
  6. the user login Moodle. Moodle displays a 'authentication requested by NAME_OF_THE_APP' button
  7. the user accepts and Moodle sends (displays ?) a Mobile ws token to the APP
  8. the APP tests the connection

Technical specifciation

A simple intro of how OAuth works, let's say moodle mobile app is a oauth client, moodle website as oauth server.

  1. oauth client needs consumer key and consumer secret to initiate an oauth session
  2. oauth client create signature by HMAC-SHA1 using consumer secret, consumer key, timestamp, nonce, callback, sending signature along with these parameters(except secret) to oauth server, then you got oauth token, oauth token secret
  3. oauth client open authorize_url (using oauth token as parameter), leave oauth token secret in client, click 'approve' button in authorize_url
  4. oauth server will direct you to your callback url, The callback request informs the client that user completed the authorization process
  5. Now use oauth token and oauth token secret to request access key (need to generate a new signature), store access key and access secret in oauth client, this is the final credentials you need for request protected resource, it need to be included in http header and the signature need to be updated as well.