Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-58823

Controlled links redirections (googledocs and onedrive) are not working in webservice/pluginfile.php

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Create a Token for a user.
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Configure your site to use the Google Oauth: https://docs.moodle.org/dev/OAuth2_Services.
      4. Enable the Google Drive repository and assign the Google OAuth 2 service to it.
      5. Make sure to set "Supported files" to "Internal and External" and "Default return type" to "External (only links stored in Moodle)"
      6. Now go back to to Site administration > Server > OAuth 2 Services and connect a system account for the Google OAuth 2 service.
      7. Create a course and enrol the user from step 2.
      8. Create a File resource from the Google Drive repository. Make sure to select "Create an access controlled link to the file" and set Display to Embed. (the file should be a google doc file, not to an uploaded file to the repository)
      9. Open the File resource, inspect the page and copy the URL from the iframe. It should be something like this:
        https://YOURSITE/pluginfile.php/180/mod_resource/content/2/File.gdoc
      10. Now you'll have to modify the URL you copied in the previous step. Add webservice/ right before pluginfile.php, and also add the user token as a param at the end. Using the example for the previous step:
        https://YOURSITE/webservice/pluginfile.php/180/mod_resource/content/2/File.gdoc?token=2155003aac9cf435ac186fb9c64fec39
      11. Open this URL in a browser in incognito mode. You should be redirected to the Google doc
      12. You may repeat the steps but this time setting up the OneDrive repository (instructions to set up here MDL-58535)
      Show
      As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for a user. Click on Site administration ► Plugins ► Web services ► Manage tokens Configure your site to use the Google Oauth: https://docs.moodle.org/dev/OAuth2_Services . Enable the Google Drive repository and assign the Google OAuth 2 service to it. Make sure to set " Supported files " to " Internal and External " and " Default return type " to " External (only links stored in Moodle) " Now go back to to Site administration > Server > OAuth 2 Services and connect a system account for the Google OAuth 2 service. Create a course and enrol the user from step 2. Create a File resource from the Google Drive repository. Make sure to select " Create an access controlled link to the file " and set Display to Embed . (the file should be a google doc file, not to an uploaded file to the repository) Open the File resource, inspect the page and copy the URL from the iframe. It should be something like this: https://YOURSITE/pluginfile.php/180/mod_resource/content/2/File.gdoc Now you'll have to modify the URL you copied in the previous step. Add webservice/ right before pluginfile.php, and also add the user token as a param at the end. Using the example for the previous step: https://YOURSITE/webservice/pluginfile.php/180/mod_resource/content/2/File.gdoc?token=2155003aac9cf435ac186fb9c64fec39 Open this URL in a browser in incognito mode. You should be redirected to the Google doc You may repeat the steps but this time setting up the OneDrive repository (instructions to set up here MDL-58535 )
    • Affected Branches:
      MOODLE_33_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-58823-master

      Description

      webservice/pluginfile.php is defined as AJAX_SCRIPT (so exceptions are returned in json format)

      This means that the redirect() function will throw an exception if is called via that file.

      The new repositories (googledocs and onedrive) uses redirect for redirecting the user to controlled links, this means that we won't be able to see those files when using webservice/pluginfile.php from the mobile app

      After discussing this with Damyon, he agreed that we can replace the redirect with header('Location' . ) and create a follow-up issue to discuss what to do. It seems that the redirect function should be the one being used.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  15/May/17