Clasp run - Error: Local client credentials unauthenticated. Check scopes/authorization - google-apps-script

I'm trying to locally run apps script after installing clasp. So far I have logged in and pulled the scripts locally. Now following https://github.com/google/clasp:
$ 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.googleapis.com%2Fai
Authorization successful.
Default credentials saved to: ~\.clasprc.json (C:\Users\me\.clasprc.json).
$ clasp run testGET
Error: Local client credentials unauthenticated. Check scopes/authorization.
What am I doing wrong?

Related

Can´t deploy to firebase cloud function

When I try to run an firebase deploy --only functions I get this error for ALMOST every function:
"WARNING: Failed to delete temporary cache image to stable name; this will not affect current build: DELETE https://*****/gcf-artifacts/application--on_application_write/cache/manifests/4500b6e2-9253-4d70-8c91-5ba800c62978: DENIED: Permission "artifactregistry.repositories.deleteArtifacts" denied on resource "projects/*__/repositories/gcf-artifacts" (or it may not exist)""
Can someone tell me what to do? Which account does not have the permission? Is it my admin-sdk service account?
You will need to grant your account the "artifactregistry.repositories.deleteArtifacts" permission on the "gcf-artifacts" repository. This can typically be done using the Cloud Console or the gcloud command-line tool. For example, you can use the following gcloud command to grant the necessary permissions to the service account associated with your Firebase project:
gcloud projects add-iam-policy-binding <PROJECT_ID> \
--member serviceAccount:<SERVICE_ACCOUNT> \
--role roles/artifactregistry.repositorie.deleteArtifacts
Replace <PROJECT_ID> with the ID of your Firebase project, and <SERVICE_ACCOUNT> with the email address of the service account that you are using to deploy your functions.

how to verify what is the current account clasp is logged in to?

I'm using clasp to develop google app scripts projects with Visual Studio Code under various google accounts. So whenever I switch project to work on, I might need to logout from the current account - clasp logout ,and clasp login in to another account.
Is there a way to check what is the current account clasp is logged in?
You can use command
clasp login --status
Example:
$ clasp login --status
You are logged in as user#domain.com.

Clasp Could not read API credentials. Are you logged in globally?

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

Getting error while deploying code from local Git to Azure via Azure CLI

I am trying to push my code from a protected Git repo via Azure CLI, but I am getting the below error:
az webapp deployment source config --branch *** --manual-integration --name **** --repo-url ***** --resource-group ****
Error
The server name or address could not be resolved
If you want to deploy code from local Git, please make sure you have installed the Git, then follow the steps below.
1.Login and configure a deployment user
az login
az webapp deployment user set --user-name 'joyw1' --password 'Password01!'
2.Get the deployment URL
az webapp deployment source config-local-git -g <group-name> -n <webapp-name>
3.Open a local terminal window to your local Git repository.
4.Add an Azure remote, replace the with the one in step 2.
git remote add azure <url>
Then run the command to push to Azure, it will let you to input the username and password, just input them that you set in the step 1.
git push azure master
For more details, you could refer to this doc - Local Git deployment to Azure App Service.

clasp : unknown option creds

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.