1

我正在登录,clasp login --creds <file>它会生成一个本地 .clasprc.json 文件。它说我已登录,但是当我运行另一个命令时,我得到:

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

关于为什么不先查看我的本地 clasprc 文件的任何想法?

当前使用版本 clasp v. 2.2.0

4

2 回答 2

2

我在 Windows 10 上遇到了同样的问题,发现你需要全局和本地登录才能使用clasp run. 您的项目文件夹和用户文件夹中都应该有一个 .clasprc.json 文件。

于 2020-05-07T16:59:08.710 回答
0

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

于 2020-04-17T14:42:08.307 回答