Node.js を使用して、Google ブック API とパスポートを使用して Google の認証戦略を使用してブック ライブラリ アプリを作成しようとしています。これまでのところ、認証して API にアクセスできます。ばかげた質問かもしれませんが、データをコレクション ビューで使用できるようにするにはどうすればよいでしょうか。認証後に Google データにアクセスした後、コレクションにリダイレクトする必要がありますが、そのデータを新しいビューに組み込むにはどうすればよいですか?
app.get('/auth/google', passport.authenticate('google', {
scope: ['https://www.googleapis.com/auth/books', 'https://www.googleapis.com/auth/userinfo.profile']
}));
app.get('/auth/google/callback', passport.authenticate('google', {failureRedirect: '/'}), function (req, res) {
// Successful authentication, get data and redirect to user collection
googleapis.discover('books', 'v1').execute(function (err, client) {
oath2Client.credentials = {
access_token: req.user.accessToken,
refresh_token: req.user.refreshToken
};
var req1 = client.books.mylibrary.bookshelves.list().withAuthClient(oath2Client);
req1.execute(function (err, bookshelves) {});
});
res.redirect('/collection');
});
app.get('/collection', routes.collection, function (req, res) {});