1
votes

I'm trying to be OAuth2-authorized by using the gapi library from inside an HtmlService project. I've got my CLIENT_ID from the console and I've set up the "Authorized Javascript Origins" with all of what I could think about like "https://script.google.com", "https://script.googleusercontent.com", etc, but I always end with an "origin mismatch" error.

This is the code I'm using from inside the html javascript code.

function checkAuth() {
  gapi.auth.authorize({
    'client_id': CLIENT_ID,
    'scope': SCOPES,
    'immediate': false
  }, handleAuthResult);
}

What am I doing wrong?

Thanks

1
Have you double checked and followed what was mentioned in the docs? - AL.

1 Answers

2
votes

To get the origin you need launch your webapp. Right click and click Inspect. This should open Devtools. Click on the Elements tab. Look for the iframe with the id="sandboxFrame". The source the that iframe in your webapp origin. It will look like:

webapp origin as seeen in devtools

When you add it to your credentials just add the domain part leaving off the endpoint.

https://n-rilyfaex6q3..iimkn7ufgvlphhi2..l3l73y-0lu-script.googleusercontent.com