在我的网络应用程序中,我使用
火力基地 要登录用户,成功登录后我得到的是这样的对象:
{
uid: ...
...
stsTokenManager: {
accessToken: ...
apiKey: ...
expirationTime: ...
refreshToken: ...
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用此信息向 YouTube v3 API 发出授权请求?是否可以?
我已阅读文档页面,据我所知,我已尝试使用此标头发送请求:
{"Authorization" : "Bearer "MY_TOKEN""}
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
超出了未经身份验证的使用的每日限制。继续使用需要注册。
我在使用 Express 4 和静态文件时遇到问题。成功登录后,我将我的网络应用程序重定向到“/home/userId”,但随后,我在所有静态文件上收到 404 错误。这是我的路由器:
router.get('/home/:userid', function(req, res, next) {
// TODO check if token is valid
User.findById(req.params.userid).exec(function(err, find) {
if (err) return next(err);
if (!find) {
return res.json(utils.createErrorJsonResponse(404, "User not found!"));
}
return res.render('home', {
title: 'Organizator',
user: find
});
})
});
Run Code Online (Sandbox Code Playgroud)
我认为向你展示我的jade文件是没有用的,唯一重要的是有很多导入的脚本,但仅举一个例子,这就是我加载css文件的方式:
link(href='css/style.css', rel='stylesheet')
Run Code Online (Sandbox Code Playgroud)
这就是我设置静态文件的方式
app.use(express.static(config.root + '/public',{ maxAge: 86400000 }));
Run Code Online (Sandbox Code Playgroud)
其中“config.root”是我的:
path.normalize(__dirname + '/..')
Run Code Online (Sandbox Code Playgroud)
正如我之前所说,如果我连接到基本页面,那么就我而言:
http://localhost:3000
Run Code Online (Sandbox Code Playgroud)
我所有的静态文件都已导入,但是一旦我重定向,我就会收到 404。那么我该如何修复它呢?例如。我有一个名为“style.css”的样式文件。在控制台的基本页面(' http://localhost:3000 )中我可以看到:
Request URL:http://localhost:3000/css/style.css
Request Method:GET
Status Code:200 OK (from cache)
Run Code Online (Sandbox Code Playgroud)
然后从“ http://localhost:3000/home/ ”:
Request URL:http://localhost:3000/home/css/style.css
Request Method:GET …Run Code Online (Sandbox Code Playgroud)