403 error - The Caller does not have permisson - javascript

I'd like to use Google Execution Api from my chrome extension.
On the page below, there is a form to test execution api request, but when I send request, I get 403 error as response.
This person who posted this question seems to have solved his problem which is probably the same problem as mine.
Why does my apps script deployed as API executable return Permission Denied?
But, I can't solve this error. Please guide me to help me this error.
Request
This is what I input into request form.
https://developers.google.com/apps-script/execution/rest/v1/scripts/run#try-it
Response
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
Project Key : MVO00WF1oNYdJ7YvOZGxXh_z7UcVTY4Um
Scopes
I use spread sheet api so, I added spread sheet scope as additional scope for OAuth 2.0.
code.gs
This is a sample function code to call.
// This function does nothing. Just a test.
function myFunction(data) {
var sheet = SpreadsheetApp.getActiveSheet();
return "success!!";
}
The script associated with project
Additional Info
I deployed my project as API executable.
I enabled execution API on developer console.
I made OAuth 2.0 Client ID on developer console.
Reference
https://developers.google.com/apps-script/guides/rest/api#limitations

is the script public or for your use only? I got this error and it resolved when I made the script public. I was doing an Android app so the answer may not apply completely.

I was having similar problems running through the quickstart documentation provided by Google. I noticed you have two items in your scope. Be careful that you add the second scope to your array. For me, I was using the node.js quickstart so line 10 looked like this:
var SCOPES = ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/spreadsheets'];
Also, as the line above this one (lines 8-9) indicates, I had to rm my previous credentials. Go to your home directory and find (the hidden) folder .credentials. for me the command was:
me#mydrive:~/.credentials $ rm script-nodejs-quickstart.json
One I did this, I re-ran my script, got authorized, and had it all working.

Your 403 error indicates that you have incorrectly or missed some configuration in authentication for your service account. Make sure the app script is associated with correct dev console project.
The script should be associated with the dev console project id that corresponds with OAuth 2.0 client ID used (this dev console project should also have "Apps Script Execution API" enabled).
To change the developer console project for an app script select the following menu item: Resources > Developer Console Project.

I had the same problem yesterday: I got the same error although I did everything correct.
I solved it by having deleted the .credentials file und rerun the code. Try it out if didn't do that before.

Related

"A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received", What does that mean?

I'm working on a React application and I use some npm modules, one of which I had to build myself. (my NPM package:
https://www.npmjs.com/package/modale-react-rm).
It is a simple modal that opens and closes with a useState().
After importing my package, I have an error in my console that appears suddenly after a few seconds without performing any actions.
Uncaught (in promise) localhost/:1
>{message: 'A listener indicated an asynchronous response by r…age channel closed before a response was received'}
message: "A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received"
>[[Prototype]]: Object
>constructor: ƒ ()
>[[Prototype]]: Object
/* sometimes there are specific elements in addition but I could not check when they appear and when not */
Promise.then (asynchrone)
(anonyme) #content_script_bundle.js:108
handleNewFeatures #content_script_bundle.js:101
handleUpdatedNodes #content_script_bundle.js:101
(anonyme) #content_script_bundle.js:101
childlist(asynchrone)
0 #purplebox.js:1
(anonyme) #purplebox.js:1
v #purplebox.js:1
It doesn't block my pages, nor does it prevent the proper functioning of its features, but it's an error and I think it should be fixed and maybe help other people who have the same problem.
I specify that I do not make any async request in this project. Everything is local and the few data I use are directly imported in raw.
I don't know where Purplebox.js comes from as well.
This issue is a cross-origin request issue and it is caused by various Chrome Extensions.
I had this too in my Angular app and after testing it in the incognito mode, the error didn't show up anymore.
More info: Google Forum
/Edit:
If you are an extension developer coming here: You need to return true when fetching data from cross-origins. More info: Chromium Project
In my case, it is caused by Ghostery extension, if this error appears in your local host, you need to add it to the trusted sites list of Ghostery and the error will be gone.
It has been discussed in the webextension-polyfill library, which is used by many extensions (including Ghostery). There was a recent change in Chrome that introduced to the error message.
For projects that are using the polyfill, I would expect the warning to go away if a fix is merged. Note that the polyfill library is used, since only Firefox implements the new promised-based runtime.onMessage, while Chrome still enforces the original callback-style API.
Note that there is an open pull request in the webextension-polyfill library already. It has not been merged, but according to my tests, it solves the problem. So, if you need a quick fix for a project that uses the library internally, you can manually apply the patch with patch-package. For instance, this is how such a change would look like in Ghostery.
The background script (service worker in MV3) could be going to inactive state without sending a response back to a message it received from a content script.
Example:
Background script:
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// ... handle message
return true // Error message says you already return true
})
Most MV3 APIs are asynchronous and can return promises when it makes sense to do so. (In some cases, like event listeners (e.g.: chrome.tabs.onRemoved), returning a promise wouldn't make sense). Reading a response back however can be done using callbacks or promise-style.
Content script: method 1 to read response:
chrome.runtime.sendMessage('ping', (response) => { /* read response */ })
Content script: method 2 to read response:
chrome.runtime.sendMessage('ping').then(response => { /* read response */ })
The issue you are facing is this: background script does not invoke sendResponse() for one/more messages it received and went inactive (causing the message channel to close). However, the content script that sent the message is waiting for the response.
Please check your message senders & handlers.
I had the same error. I removed the Tampermonkey extension and tweaked my AdBlock extension and then it worked for me.
I encountered the same issue couple of days ago, and found out that the source of error is located in the background.js.
it's caused by the runtime Message Handler. to solve it, just add a third parameter as a callback function to chrome.runtime.onMessage.addListener.
forgot how i found the solution, but it works for me.
// to avoid the error, the parameter [sendResponse] is necessary!
chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {
// do something ...
// this line seems meaningless but you have to invoke it to avoid error.
sendResponse({damn: true});
});
This error is related to ad blockers or similar. Just exclude the site for this application.
In my case it was AdBlock app. It kept showing this error in the console when working with LiveServer or FiveServer. It does not affect anything, but it is very annoying
I had the same error on my react app when i introduced an infinite loop through useEffect, the thing is that you most likely won't see too much change in your app or problem. For me it even helped reload some state for functions that i was still to write but over time it will introduce bugs and performance issues.
Avast Online Security & Privacy 22.11.173 is causing the same issue.
I had the same issue on my Windows 11 machine.
I added these lines at the bottom of the hosts file in the drivers/etc directory:
127.0.0.1 localhost
::1 localhost
This solved the problem for me.
I faced the same error. Where class Component didn't show any response over display.
Solution : Syntax error in spelling "render" => ~"rendor"~

socket.io "net::ERR_FAILED" with cache manifest for Progressive Web App

I'm developing a Progressive Web App which uses a .manifest file to cache all files on the client. I modified the socket.io chat example which is found here:
https://github.com/socketio/chat-example
my modifications can be found here:
https://github.com/TennisVisuals/socket.io.manifest.errors
The first change in the client code is:
external resources (jquery and socket.io client libraries) are accessed locally rather than via remote URLs.
Everything works as expected.
But with the second change:
<html> is replaced with <html manifest="index.manifest">
The application fails, giving this error in the Javascript console:
http://localhost:3000/socket.io/?EIO=3&transport=polling&t=Lij1LRo net::ERR_FAILED
Initial Fix
I've been able to make it work locally by adding the following lines:
enter var connectionOptions = {
"force new connection" : true,
"reconnectionAttempts": "Infinity",
"timeout" : 10000,
};
var socket = io(connectionOptions);
Cloudflare and Nginx
But I'm now seeing stranger behavior when I run with Cloudflare and Nginx.
Without the manifest declaration I get an error, but everything still works!
socket.io-1.7.2.js:7370 WebSocket connection to 'wss://hiveeye.net/socket.io/?EIO=3&transport=websocket&sid=rM2LKvCGJwaFx7RrAAAf' failed: Error during WebSocket handshake: Unexpected response code: 400
after adding the manifest declaration it works exactly once and then fails with the following errors:
socket.io-1.7.2.js:4948 GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5SC5&sid=rM2LKvCGJwaFx7RrAAAf net::ERR_FAILED
GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5STN net::ERR_FAILED
GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5STN net::ERR_FAILED
I suspect that if I can get the initial error to go away when running without the manifest, that may do the trick... but I've been unable to find anything to help me resolve that issue...
Ok, this was really simple once I found out how to ask the right question
Adding:
NETWORK:
*
at the bottom of the manifest file made everything work.
Yes, the "Application Cache" is deprecated:
https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache
but I still wanted to make it work!!

Google Sheets API node.js quickstart won't work: The API returned an error: Error: unauthorized_client

I've been messing with the Google Sheets API for a project and everything has been going pretty well. I followed all the steps On this page and got the quickstart working great for a while... Until I ran into an issue where I was getting the error message API returned an error: Error: The request does not have valid authentication credentials.
To resolve this I tried a bunch of different things from changing the SCOPES variable to commenting and uncommenting out things.
Eventually I deleted the project and credentials on my google developers console account and tried to make a new one.
Whenever I start a new folder from scratch, make a quickstart.js file, install the node modules and run it, now I get The API returned an error: Error: unauthorized_client. I've made completely new client_secret.json files and made the quickstart.js from scratch directly using the quickstart walkthrough code and it won't work. What could be causing this?
Link to github (this is the code that WAS mostly working until I tried to delete rows from my google sheet after copying data to my sql database).
You may want to try what was done in this SO post wherein this hidden file has been deleted:
/Users/user/.credentials/gmail-nodejs-quickstart.json
In your case, you need to locate the path of sheets.googleapis.com-nodejs-quickstart.json then delete.
For this, you might need to also do a console.log to locate the correct path.

GET Soundcloud connect SDK is returning 404

I am making a GET request for the connect sdk script: https://connect.soundcloud.com/sdk/sdk-3.1.2.js, which has never before failed me before. This file is the one the documentation says to use. However when I make a GET request to: https://connect.soundcloud.com/sdk/sdk-3.1.2.js in a script tag, postman, and in my browser url bar, the return status is 404 Not Found.
Please help me, as my application artistsunlimited.co uses the connect api heavily.
It looks like they deployed some code today; this may be related, because I was not getting this error yesterday. Hopefully they will fix this issue soon.
See status message here.

App Engine Channel API's Javascript Client Isn't Using my onError Callback

I'm using App Engine's Channel API to maintain a connection between a Chrome extension and an App Engine app. You can see my Channel-related code here: https://github.com/2cloud/Chrome/blob/3fe70262ef69ae8286a057055f4108760560c47e/socket.js (The app is open source, so you can check out the repository to get an idea of how it all fits together)
My issue is, for some reason, the 401 error that App Engine throws when a token expires isn't being sent to my onError listener. I've tried just logging the error object from within onError, outside of an if statement, and still got nothing. My conclusion was that onError isn't getting called when a 401 is thrown, as the documentation says it's supposed to.
Has anyone else seen this error? Does anyone else have an idea on how to fix it?
I've reproduced this bug and started work fixing it. http://code.google.com/p/googleappengine/issues/detail?id=5685

Categories

Resources