google-apps-scriptweb-applicationsgoogle-oauthyahoo-api

How do get the url "https://script.google.com/macros/d/{SCRIPT ID}/usercallback" responding / up and running


I'm a beginner in Google Apps Script.

I'm basically trying to use the OAuth service in a Google Apps Script to be able to connect a Google spreadsheet to Yahoo fantasy API.

I'm using the package you can found here: https://github.com/googleworkspace/apps-script-oauth2

In the "read me" part you can see that oauth libraries will by default use the callback url https://script.google.com/macros/**d**/{SCRIPT ID}/usercallback

So I try to use this package in my script, but when I publish my script it creates the following url:

https://script.google.com/macros/**s**/{SCRIPT ID}/

Notice it's an "s" instead of the "d" in the url.

I can access properly to https://script.google.com/macros/**s**/{SCRIPT ID}/exec and so on but the url containing the "d", which is expected to be use by OAuth service, return an error.

When trying to access the url in a browser I got:

.. is https://script.google.com/macros/**d**/{SCRIPT ID} in that case.

I've been looking on internet for having this url working but no success (it that so obvious that no one else had the issue except me?). I tried several thing, i've created a project and linked my script to that project, i played a bit with the configuration in the project in regards to what i found on internet, like credential for API, but still can't have the url with a "/d/" responding.

I'm not sure of the meaning of the "s" (script?) or the "d" in the url.

I'm not sure if it has something to do with the way I publish my script or if I need to have specific function in my script or maybe some configuration of the script, maybe I need to persevere with the project thing...


Solution

  • I think that you should re-read the Readme.md file from the Google OAuth Sample GitHub repo. Also I think that d and s parts of Google Apps SCript URLs are irrelevant for using the "OAuth Service".

    The .../exec URL is generated when making a new deployment. This URL doesn't contain the script Id... please bear in mind that a single Google Apps Script project might be deployed multiple times and have all or some deployments being live at the same time. Each web app deployment will have it's own URL... none of them have the script id. By the other hand, you might not need to make a deployment in order to be able to use "the OAuth service", this is needed only if the script will be receiving GET/POST HTTP requests.

    You should not to access the ../usercallback in the browser, as you will be doing a GET request without proving the required data. This URL should be added when getting the credentials to be used with the "OAuth Service" from the OAuth provider, in this case Yahoo, as the redirect URI.

    The referred repo includes multiple samples about how to use the "OAuth Service", one of the is Yahoo.gs

    Resources