我有一个 HTML sendgrid 模板,正在使用 npm 包“sendgrid”通过 Node.js 发送它。问题是我总是以文本格式而不是 HTML 接收电子邮件,即使模板具有 HTML。
代码:
var email = new sendgrid.Email({
to : 'me@here.com',
from : 'you@there.com',
subject : 'Saying Hi with HTML Template',
text : 'Body' //This is required
});
email.addFilter('templates', 'enable', 1);
email.addFilter('templates', 'template_id', '12131331.....');
email.addSubstitution('{{TOKEN1}}', 'value');
sendgrid.send(email, function(err, json) {
if (err) { console.error(err); }
console.log(json);
});
Run Code Online (Sandbox Code Playgroud)
模板
<html>
<head><title></title></head>
<body>
<h1>This is a test</h1>
<p>{{TOKEN1}}</p>
<p><a href="http://www.there.com">There</a></p>
<div><%body%></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
是否有我应该设置的代码参数?还是模板本身的设置以允许 HTML?
我有一个MongooseJS架构,其中父文档引用一组子文档:
var parentSchema = mongoose.Schema({
items : [{ type: mongoose.Schema.Types.ObjectId, ref: 'Item', required: true }],
...
});
Run Code Online (Sandbox Code Playgroud)
为了进行测试,我想在父文档中使用一些虚拟值填充item数组,而不将它们保存到MongoDB:
var itemModel = mongoose.model('Item', itemSchema);
var item = new itemModel();
item.Blah = "test data";
Run Code Online (Sandbox Code Playgroud)
但是当我尝试将此对象推入数组时,只_id存储了以下内容:
parent.items.push(item);
console.log("...parent.items[0]: " + parent.items[0]);
console.log("...parent.items[0].Blah: " + parent.items[0].Blah);
Run Code Online (Sandbox Code Playgroud)
输出:
...parent.items[0]: 52f2bb7fb03dc60000000005
...parent.items[0].Blah: undefined
Run Code Online (Sandbox Code Playgroud)
我能以某种方式做相当于`.populate('items')吗?(即:从MongoDB中读取文档时填充数组的方式)
我将ADFS3 OAuth2配置为返回Refresh Tokens:
PS> Set-AdfsRelyingPartyTrust -TargetName "RPT Name" -IssueOAuthRefreshTokensTo AllDevices
PS> Set-AdfsRelyingPartyTrust -TargetName "RPT Name" -TokenLifetime 10
PS> Set-AdfsProperties -SSOLifetime 480
Run Code Online (Sandbox Code Playgroud)
Access Token持续10分钟,Refresh Token持续480分钟.
然后我通过GETing生成一个访问令牌:
https://myadfsdomain/adfs/oauth/authorize
?response_type=code
&client_id=MYCLIENTID
&redirect_uri=https://myserver/callback
&resource=MYRelyingPartyId
Run Code Online (Sandbox Code Playgroud)
并发布responseCodeEg:
$http({method: "post",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
url: "https://myadfsdomain/adfs/oauth2/token",
data: "client_id=MYCLIENTID&code=" + responseCode + "&redirect_uri=https://myserver/callback&grant_type=authorization_code" })
Run Code Online (Sandbox Code Playgroud)
响应具有访问令牌,类型,过期时间和刷新令牌:
{"access_token":"blah...",
"token_type":"bearer",
"expires_in":600,
"refresh_token":"blahblah..."}
Run Code Online (Sandbox Code Playgroud)
大.访问令牌现在有效,无论它配置多久(这里10分钟)
问题是,一旦该时间到期,我们如何使用它refresh_token来获取另一个访问令牌?IE:
refresh_token?我有以下脚本.
type SetCookie = {
NameValue : string * string;
Domain : string option;
Path : string option;
Expires : string option;
MaxAge : string option;
Secure : bool; // ? no associated value, anything better than bool
HttpOnly : bool; // ? no associated value, anything better than bool
}
let GetCookie str =
let allkeyvalues =
str.Split ';'
|> Array.map (fun str ->
match str.Split '=' with
| [| key |] -> (key.Trim(), "")
| [| key; value …Run Code Online (Sandbox Code Playgroud)