5 Replies Latest reply on Mar 15, 2016 10:31 PM by user19752

    Accessing other fmp:// URL parameters

    michaelmoore

      Hello,

       

      Is there any way to access URL parameters that don't start with a dollar sign, or to access the whole fmp:// URL that was used to trigger a script?

       

      eg. I need to extract the value xyz from the code parameter from this URL:

       

      fmp://$/TestFile.fmp12?script=testScript&param=abc&code=xyz

       

      I'm not in control of the code=xyz part of the url, so I can't change it.

       

       

      Background:

       

      I'm implementing Oauth2 in a web viewer.

       

      The Oauth2 server will happily send my users to an fmp:// URL so that I can handle the second leg of Oauth2 with a script, but they're being smart about appending the auth code to my fmp URL, and making sure that any open parameters are closed before appending.

       

      Callback URLResulting URL
      fmp://$/TestFile.fmp12?script=testfmp://$/TestFile.fmp12?script=test&code=xyz
      fmp://$/TestFile.fmp12?script=test&$fmp://$/TestFile.fmp12?script=test&$&code=xyz
      fmp://$/TestFile.fmp12?script=test&param=fmp://$/TestFile.fmp12?script=test&param=&code=xyz
        • 1. Re: Accessing other fmp:// URL parameters
          user19752

          I think there is no way to get it in FM.

           

          Where do you get the result ? Can't you adapt it in your web viewer code before redirect?

          So, how does it work if call back URL is data:text/html...

          • 2. Re: Accessing other fmp:// URL parameters
            michaelmoore

            The service I'm providing requires that the callback have a valid URI scheme, it won't take data:text/html.

             

            OAuth2 is a bit messy, but basically in FileMaker we send the user to a 3rd party site. The user logs into the 3rd party site, at which point the 3rd party site asks if the user wants to grant FileMaker access to the 3rd party services. If the user clicks "Grant", then the 3rd party site redirects the user back to the callback URL, with the temporary code in the URL.

             

            We then use the temporary code and our API key to make a background HTTP request back to the 3rd party site. If the code and the API key are valid, the 3rd party site sends us an access token. We can then interact with the 3rd party service on behalf.

             

            Basically, during the actual authentication process control over the contents of the web view in control of the 3rd party site. The actual redirect to the fmp:// url is done by the 3rd party site upon completion of the Oauth2 provider, so I can't intercept it before the script is running.

            • 3. Re: Accessing other fmp:// URL parameters
              user19752

              Thanks for description.

               

              So is file://...  valid?

              You can make a html that contain redirection to fmp: URL rebuilding parameters, then use it as callback.

              If file:// is not acceptable, you need a web server to put the html.

              • 4. Re: Accessing other fmp:// URL parameters
                michaelmoore

                Thanks for the quick responses.

                 

                file:// should be valid and is a good idea, but I don't think it'll work in this case. The callback URL needs is set in the Oauth2 configuration on the 3rd party site, so the callback has be the same for all users where our FileMaker solution will be installed. We'll have a mix of Windows and Mac users, and users could potentially have FileMaker installed in different paths on their computers. The file:// path would need to be different for each of these cases.

                 

                If file:// is not acceptable, you need a web server to put the html.

                 

                That's what we're doing right now, and it does work. Literally all it does is look at the code=xyz value in the url and open an FMP script. I was hoping to be able to move it into the FileMaker script and have one less moving piece in this solution.

                • 5. Re: Accessing other fmp:// URL parameters
                  user19752

                  Unfortunately current version of FM may not.

                   

                  The rest is changing fmp: protocol handler to add $ in URL.

                  Or fmp: is acceptable, so writing another protocol that call fmp: may be easier?

                  Anyway this is change of system configuration, so seems not good idea...