- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 clasp 的新手。
通过以下方式初始登录后:扣登入我可以登录到 script.google.com接下来,我创建了一个项目并通过以下方式推送文件:扣压
现在,我已经退出使用:扣环注销
此处需要帮助:现在,如果我正在尝试:
clasp 登录 --creds ./.clasp.json
我收到“检索访问 token 时出错:TypeError:无法读取未定义的属性‘project_id’”。
请指导我如何通过 --creds 登录?
最佳答案
TLDR:您使用的是配置文件 ( .clasp.json
),而不是来自 Google Cloud 项目控制台的凭据文件( creds.json
或其他文件)。
当您登录时,凭证的默认存储在名为 .clasprc.json
的文件中 在~
目录(Windows 上为 C:\Users\<user>\
):
$ clasp login
Logging in globally...
🔑 Authorize clasp by visiting this url:
https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&.....
Authorization successful.
Default credentials saved to ~\.clasprc.json (C:\Users\<user>\.clasprc.json).
请注意,此文件 ( .clasprc.json
) 与 .clasp.json
不同.
据称此文件的内容取决于身份验证类型,全局或本地:
// GLOBAL: clasp login will store this (~/.clasprc.json):
{
"access_token": "XXX",
"refresh_token": "1/k4rt_hgxbeGdaRag2TSVgnXgUrWcXwerPpvlzGG1peHVfzI58EZH0P25c7ykiRYd",
"scope": "https://www.googleapis.com/auth/script.projects https://www.googleapis.com/auth/script ...",
"token_type": "Bearer",
"expiry_date": 1539130731398
}
本地身份验证存储客户端密码/等,如果您计划使用 clasp run
,通常需要这样做。通过 Google Apps 脚本 API 执行功能。
// LOCAL: clasp login will store this (./.clasprc.json):
{
"token": {
// as above
},
// Settings
"oauth2ClientSettings": {
"clientId": "807925367021-infvb16rd7lasqi22q2npeahkeodfrq5.apps.googleusercontent.com",
"clientSecret": "9dbdeOCRHUyriewCoDrLHtPg",
"redirectUri": "http://localhost"
},
"isLocalCreds": true
}
(实际上,这两个文件都将具有 LOCAL
文件的格式——属性 token
、oauth2ClientSettings
和 isLocalCreds
——尽管对于全局登录,isLocalCreds
的值将为 false .)
{
"scriptId": "",
"rootDir": "build/",
"projectId": "project-id-xxxxxxxxxxxxxxxxxxx",
"fileExtension": "ts",
"filePushOrder": ["file1.ts", "file2.ts"]
}
请注意 clasp.json
是脚本文件的配置 和clasprc.json
存储 用户的凭据/授权。 都不是它们都不是用于本地登录的适当凭据文件。
您收到的特定错误是由于您提供了不正确的文件。您提供的“凭据”文件没有所需的属性,因此当 clasp 尝试 read from that property 时
console.log(LOG.CREDS_FROM_PROJECT(options.creds.installed.project_id));
你得到错误:
Error retrieving access token: TypeError: Cannot read property 'project_id' of undefined
您可以从 Apps 脚本项目的 Google Cloud 项目页面获取正确的凭据文件,即 https://console.cloud.google.com/apis/credentials?authuser=0&project=<some project id>
此文件的格式为:
{
"installed":{
"client_id":"<stuff>.apps.googleusercontent.com",
"project_id":"<some project id>",
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
"token_uri":"https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
"client_secret":"<more stuff>",
"redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]
}
}
如果您的凭据文件没有这种格式,您将无法使用它在本地登录。
关于clasp - 检索访问 token : TypeError: Cannot read property 'project_id' of undefined 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54533397/
我只是有一个更琐碎的问题。 为什么undefined == undefined 返回true,而undefined >= undefined 为false? undefined 等于 undefine
用PHP 7.2编写套接字服务器。根据Firefox 60中的“网络”选项卡,服务器的一些HTTP响应的第一行随机变为undefined undefined undefined。因此,我尝试记录套接字
在 JavaScript 中这是真的: undefined == undefined 但这是错误的: undefined <= undefined 起初我以为<=运算符包含第一个,但我猜它试图将其转换
在回答这个问题 (Difference between [Object, Object] and Array(2)) 时,我在 JavaScript 数组中遇到了一些我以前不知道的东西(具有讽刺意味的
来自https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/of , Note: thi
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
当我添加 到我的 PrimeFaces Mobile 页面,然后我在服务器日志中收到以下警告 WARNING: JSF1064: Unable to find or serve resource, u
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我是一名优秀的程序员,十分优秀!