我使用下面的代码从firebase获取令牌:
const messaging = firebase.messaging();
messaging.requestPermission()
.then(() =>{
return firebase.messaging().getToken();
}).then(token => {
saveTokentoServer(user.uid, token);
})
Run Code Online (Sandbox Code Playgroud)
问题是我为不同的用户收到相同的令牌。我无法发送目标邮件。
有谁知道我如何为不同的用户获得不同的令牌?
我花了两天时间寻找答案。为什么我的Web应用程序未收到唯一令牌?
我成功地将我的 Alexa 应用程序(客户端)链接到我们公司的 OpenID Connect 平台(授权服务器)。
我们的授权服务器将以下信息返回给 Alexa 客户端:
{
"access_token":"eyAi",
"refresh_token":"kfQ",
"scope":"openid profile",
"id_token":"eyA",
"token_type":"Bearer",
"expires_in":3598
}
Run Code Online (Sandbox Code Playgroud)
Alexa 客户端成功接收此信息,并在调用技能时将“access_token”传递给我们的代码。
所以总而言之,两个系统是链接的,alexa 正在向我们发送 access_token。到现在为止还挺好。
然而,问题是我们的平台需要“id_token”而不是“access_token”。所以我希望 Alexa 向我们发送 id_token。
我找不到有关如何实现这一目标的任何文档。请帮忙。
这是在alexa下链接帐户的链接
在我的文本区域内,我希望保持距顶部30像素的填充。
textarea {
display: block;
width: 300px;
height: 50px;
padding-top: 30px;
}
Run Code Online (Sandbox Code Playgroud)
但是,一旦在文本区域中填充了文本并且内容开始滚动。不再保留填充。
当您运行此小提琴时,最初会注意到从顶部(文本区域的内部)保留了填充。但是,当您超过150个字符时,填充就消失了。
有什么解决办法吗?
我的 dynamoDB 表中的每个对象看起来都像
{
_geoloc: {lat: 123, lng: 456},
name: 'abc',
city: 'belarus',
id: 'unique1'
}
Run Code Online (Sandbox Code Playgroud)
我有以下更新表达式:
const params = {
TableName: CONFIG.dynamoDB.tableName,
Key:{
"id": location.id.toString()
},
UpdateExpression: "set city=:c, _geoloc=:g",
ExpressionAttributeValues:{
":c": location.address.city,
":g": geoCodes
},
ReturnValues:"UPDATED_NEW"
};
Run Code Online (Sandbox Code Playgroud)
DynamoDB 引发以下错误:
ValidationException: Invalid UpdateExpression: Syntax error; token: "_", near: ", _geoloc"
at Request.extractError (/Users/mv/pcode/meeting-finder-kinesis-consumer/node_modules/aws-sdk/lib/protocol/json.js:48:27)
Run Code Online (Sandbox Code Playgroud)
据我所知.. _ 是名称中的有效字符
有什么建议我可以解决这个问题吗?
在迈向TDD的过程中,我正在使用Mocha,chai和sinon。那里肯定有学习曲线。
我的目标是编写一个测试来验证method4是否已执行。我该如何实现?
//MyData.js
class MyData {
constructor(input) {
this._runMethod4 = input; //true or false
this.underProcessing = this.init();
}
method1() { return this.method2() }
method2() {
if (this._runMethod4) {
return this.method4();
} else {
return this.method3();
}
method4(){
return thirdPartyAPI.getData();
}
method3(){
return someAPI.fetchData();
}
init(){
return this.method1();
}
}
Run Code Online (Sandbox Code Playgroud)
MyData.spec.js
describe('MyData', () => {
it('should execute method 4', function() {
let foo = new MyData(true);
foo.underProcessing.then(()=>{
// How do I verify that method4 was executed ??
expect(foo.method4.callCount).to.equal(1);
});
});
})
Run Code Online (Sandbox Code Playgroud) 这是我的 serverless.yml 文件中的一个片段:
Resources:
LogGroupInfo:
Type: 'AWS::Logs::LogGroup'
Properties:
RetentionInDays: 3
FirehoseInstance:
Properties:
DeliveryStreamName: ${opt:stage}-analytics
DeliveryStreamType: DirectPut
RedshiftDestinationConfiguration:
CloudWatchLoggingOptions:
Enabled: true
LogGroupName: !Ref LogGroupInfo
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误:
unknown tag !<!Ref> in "/Users/code/Project1/serverless.yml" at line 56, column 42:
... LogGroupName: !Ref LogGroupInfo
Run Code Online (Sandbox Code Playgroud)
当在 cloudformation 中用于创建堆栈时,此模板运行良好。为什么 !Ref 被 serverless.yml 拒绝?
我的凭证文件中有多个AWS配置文件设置
[dev]
aws_key = xx
aws_secret = yy
[qa]
aws_key = aa
aws_secret = bb
[prod]
aws_key = mm
aws_secret = qq
Run Code Online (Sandbox Code Playgroud)
无论如何,在部署时是否会通知无服务器框架要使用哪些凭据?
例如:
serverless deploy --profile prod
Run Code Online (Sandbox Code Playgroud) alexa ×1
css ×1
firebase ×1
html ×1
javascript ×1
mocha.js ×1
oauth-2.0 ×1
serverless ×1
sinon ×1