I have a Google Apps Script Add-On that will not authenticate any more. It throws the following error:
Not a valid origin for the client: https://n-kn26x-script.googleusercontent.com has not been whitelisted for client ID 1061.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID.
If I check the window.location.orgin
in the console, I get exactly that *.googleusercontent.com
url.
Now whitelisting this url no longer works (it used to), it throws the following error:
The request failed because one of the field of the resource is invalid. Tracking number: c50***
The function that throws the error is the following and is run from the sidebar a Google Sheet:
function initClient() {
console.log('INIT');
return new Promise(resolve =>{
gapi.client.init({
apiKey: API_KEY,
discoveryDocs: [],
clientId: CLIENT_ID,
scope: "https://www.googleapis.com/auth/spreadsheets"
}).then(function () {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle the initial sign-in state.
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
resolve(isAuthenticated);
}).catch(
e => {
makeModal('OAUTH2', $.t('gapiLoadPb'), false);
console.log('OAuth2 GAPI Error: ' + e.details);
google.script.run.consoleOauth2Pb(e);
});
})
}
I've searched around a lot, most of the tips are around changing the project, creating new credetials, etc. I've tried all that.
I would really appreciate any help with this!