I am using the clasp to run AppScript
Example:
clasp run myFunction dev
but its showing error here like
Requested entity was not found
please let me know why it's happening?
You need to deploy the script as "API Executable". Then add sufficient authorization scopes to call the function.
Related
I have cloned a google apps script project but when trying to deploy the changes with the push command I get the following error:
PS D:\evcPRD> clasp push
No valid D:\evcPRD.clasp.json project file. You may need to create or clone a project first.
Any idea how to solve this?
Thank you
I wanted to find some library which is similar to pandas in Python and use it in my google script. I've found danfo-js https://github.com/opensource9ja/danfojs
And using this guide https://blog.gsmart.in/es6-and-npm-modules-in-google-apps-script/ did install it in google cloud shell
so, actually here what I did:
opened my google cloud shell
installed clasp tools
clasp login
npm install danfojs-node
created new google script using: clasp create --type standalone --title "first GAS App"
So now, I have this empty script and just wanted to check does it see the danfo-js library.
To check this I have filled it out with the following code:
function myFunction() {
const dfd = require("danfojs-node")
const tf = require("#tensorflow/tfjs-node")
let data = tf.tensor2d([[20,30,40], [23,90, 28]])
let df = new dfd.DataFrame(data)
let tf_tensor = df.tensor
console.log(tf_tensor);
tf_tensor.print()
}
After I run this script I am getting the following error message:
[20-10-18 06:17:53:783 PDT] ReferenceError: require is not defined
at myFunction(Code:2:15)
It links on the following line:
const dfd = require("danfojs-node")
Looks like the compiler doesn't know what is "danfojs-node" but I don't understand what steps did I miss.
I did install danfojs-node, using the following command in google cloud shell:
npm install danfojs-node
and using the same terminal window I created this script.. maybe I should set some link inside the script to connect to this library, but I don't know where should I do it.
Apps Script is not Node.js.
You cannot install external modules and libraries the same way you would when creating a node.js application. The supported way of using external libraries in Apps Script is by installing them through the project's resources.
So essentially, this can be done by going to the project's Resources > Libraries....
You have to check if the library you plan on using is supported by Apps Script and if so, include it using the step above.
Reference
Apps Script Libraries.
I am able to get the files using clasp pull command but not able to update the files using clasp push command. It says "No files to push".
When I run command clasp status then it shows all of my project files in "Ignore files". Previously it was working completely and the problem occurred yesterday when I changed my laptop.
I also tried making .claspignore file and it also did not work.
For reference, please see the screenshot.
Please help.
I think for me I found the issue after using trying
clasp version "YOUR_VERSION_STRING".
I got a console message to enable API access. Once I enabled that I was able to make pushes. It's funny because I was able to clone and pull just fine.
So this is the Settings URL and then make sure that "Google Apps Script API Access" is on.
I'm logging in with clasp login --creds <file> which produces a local .clasprc.json file.
It says that I am logged in, but when I run another command I get:
Could not read API credentials. Are you logged in globally?
Any thoughts on why its not looking at my local clasprc file first?
Currently using version clasp v. 2.2.0
I ran into the same problem on Windows 10 and found that you need to login both globally and locally to use clasp run. There should be a .clasprc.json file in both your project folder and user folder.
I think I have finally found the solution for the same problem
Follow along with the comments from this github issue
Add the "oauthScopes" field to your local code and push it to your app
If you can't push, then copy-paste it to manifest file in the browser
Then you have to publish the app, and there were few things I've done, not sure which one helped. In the app in browser:
add the app version in File->Manage Versions
Publish -> Deploy as API executable
try to login with clasp and creds.json file
try to run something clasp run testRun
it may show the error that you're missing some oauth permissions, but it will list which ones, and you can add them
In my case, one weird thing that also helped was to enable some Google API
so in the app in browser: Resources -> Advanced Google Services -> enable some API
then try to do clasp run
if it works, you can disable the API that you have enabled previously.
Hope that helps
I'm trying to run apps script locally using clasp. I'm following https://github.com/google/clasp/blob/master/docs/run.md to get set up . I'm logged in. Foolowing the directions:
$ clasp login
Logging in globally...
� Authorize clasp by visiting this url:
https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https%3A%2F%2Fwww.google........
Authorization successful.
Default credentials saved to: ~\.clasprc.json (C:\Users\me\.clasprc.json).
$ clasp open --creds
error: unknown option `--creds'
My project files are on the E drive.
If you are to lazy to clone the clasp project, build it to finally use the --creds option, you can just open the url:
https://console.developers.google.com/apis/credentials?project=...
with the parameter project with a value like: project-id-7006438181792679938
The ability to clasp open --creds was added in commit 0cd4d12. This commit came after the current release of 1.7.0
If you are not self-compiling clasp, then you do not have this functionality yet. To compile clasp, review the developer guide.