我正在做一个将一些数据写入mongodb的python脚本.完成后,我需要关闭连接并释放一些资源.
如何在Python中完成?
我目前有两个不同的项目,一个是MainAPI,它将公开我的Web客户端的功能,另一个是AuthAPI,它处理所有的auth请求,全部使用netcore 2构建.
如果我直接调用AuthAPI,它将根据需要处理请求.
当我尝试通过AuthAPI对MainAPI请求进行身份验证时,它无法执行此操作,尽管我可以看到进入和退出AuthAPI的请求.
这是我在MainAPI Startup.cs中的服务身份验证配置:
services.AddAuthentication(option =>
option.DefaultAuthenticateScheme = "Bearer")
.AddJwtBearer(options =>
{
options.MetadataAddress = "http://localhost:5019/auth/api/info";
options.Authority = "http://localhost:5019";
options.Audience = AUDIENCE;
options.RequireHttpsMetadata = false;
options.SaveToken = true;
options.BackchannelHttpHandler = new BackChannelHttpHandler();
options.IncludeErrorDetails = true;
});
Run Code Online (Sandbox Code Playgroud)
这是BackChannelHttpHandler类:
public class BackChannelHttpHandler : HttpMessageHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
HttpClient client = new HttpClient(new HttpClientHandler(), disposeHandler: false);
client.DefaultRequestHeaders.Add("Accept", "application/json");
var res = await client.GetAsync(request.RequestUri);
return res;
}
}
Run Code Online (Sandbox Code Playgroud)
我控制的控制器作为授权注释如下:
[Authorize(AuthenticationSchemes = "Bearer")]
Run Code Online (Sandbox Code Playgroud)
至于AuthAPI,我在Startup.cs中配置了Cors:
services.AddCors(options =>
{ …
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我需要链接一个现有的电子邮件帐户,而无需用户登录。我有用户的电子邮件,所以我正在尝试以下代码:
firebase.auth().getUserByEmail(useremail);
Run Code Online (Sandbox Code Playgroud)
在客户端。但它给了我firebase.auth(...).getUserByEmail is not a function error.
有谁知道如何通过客户端的电子邮件地址获取用户,以便我可以链接帐户、现有帐户和提供商?
提前致谢。
使用SDK 17.4.5
我有以下数据结构:
List<Item> Items = new List<Item>
{
new Item{ Id = 1, Name = "Machine" },
new Item{ Id = 3, Id_Parent = 1, Name = "Machine1"},
new Item{ Id = 5, Id_Parent = 3, Name = "Machine1-A", Number = 2, Price = 10 },
new Item{ Id = 9, Id_Parent = 3, Name = "Machine1-B", Number = 4, Price = 11 },
new Item{ Id = 100, Name = "Item" } ,
new Item{ Id = 112, Id_Parent = …
Run Code Online (Sandbox Code Playgroud) c# ×2
connection ×1
firebase ×1
javascript ×1
jwt ×1
linq ×1
mongodb ×1
pymongo ×1
python ×1
recursion ×1