Tag: google oauth2

在使用Google的oauth2Client.getToken()之后尝试redirect时,无法设置标题。

从谷歌收到oauth2令牌之后,我试图redirect到我的快递服务器上的端点,以提出API请求。 这是authentication请求的stream程: app.get('/api/presentation/getpresentation/:id', function(req, res, next){ req.session.user = req.user.id; req.session.presentation_id = req.params.id; res.redirect(google_auth_url) }); app.get('/oauth2callback', function(req, res) { const code = req.query.code; oauth2Client.getToken(code, function(err, tokens) { req.session.tokens = tokens; if (!err) { oauth2Client.setCredentials(tokens); res.redirect(`/api/presentation/${req.session.presentation_id}`); return; } res.status(500).send(err); }) }); app.get('/api/presentation/:id', **do things with api consent**); 错误: Error: Can't set headers after they are sent. at […]

错误:invalid_request缺less必需的参数:范围(Restify&Passportjs w / Google OAuth2)

所以,我使用Restify和Passportjs(Google OAuth2策略)遇到了Node.js应用程序的问题。 当我使用passport.authenticate() ,它给我以下错误: 400.这是一个错误。 错误:invalid_request 缺less必需的参数:范围 几年前,我发现了另外一个同样的问题( 在Google Oauth2上使用Google Passportjs时,invalid_request丢失了:范围 )。 作者说他自己终于修好了,但没有发布修复。 有没有其他人遇到这个问题,并能够解决它? 我无法弄清楚。 这是我的代码: authController.js var passport = require('passport'); var GoogleStrategy = require('passport-google-oauth20').Strategy; var auth = { google: { clientID: '<ID>', clientSecret: '<SECRET>', callbackURL: 'https://localhost:8080/auth/google/return', scope: ['profile', 'email'] } }; passport.use(new GoogleStrategy({ clientID: auth.google.clientID, clientSecret: auth.google.clientSecret, callbackURL: auth.google.callbackURL }, function(accessToken, refreshToken, profile, cb) […]

Google API NodeJS Library OAuth2请求

我正在尝试设置Google API使用授权,以便向网站站长工具API发出请求,但似乎无法理解如何触发身份validation。 我build立了一个路由,它应该在访问时触发authentication权限调用,但是我得到一个连续的负载信号,没有收到数据响应。 我正在使用Google的图书馆https://github.com/google/google-api-nodejs-client/ ,并将我的OAuth2客户端ID凭据redirect到指向http://localhost:3000/ uri,因为我想testing本地安装。 这是我的代码: index.js var express = require('express'); var app = express(); var handlebars = require('hbs'); var google = require('googleapis'); var webmastertools = google.webmasters('v3'); app.set('port', process.env.PORT || 3000); // Handlebars View Engine app.set('view engine', handlebars); app.use(express.static(__dirname + '/public')); // set the public directory app.listen(app.get('port'), function(){ console.log('Server on port'+app.get('port')); }); var routes […]

缺less必要的参数:redirect_uri与passport-google-oauth

在我的MEAN Stack应用程序中使用passport-google-oauth: "0.2.0" (在这里find: https : //github.com/jaredhanson/passport-google-oauth )。 当我运行应用程序并尝试使用Google APIlogin时,将返回此错误 这是一个错误。 错误:invalid_request 缺less所需的参数:redirect_uri 请求详细信息scope = https://www.googleapis.com/auth/plus.login response_type = code redirect_uri = client_id = xxxx-xxxx.apps.googleusercontent.com redirect参数在这里passport-init.js var GoogleStrategy = require('passport-google-oauth')。OAuth2Strategy; var GOOGLE_CLIENT_ID =“xxx-xxx.apps.googleusercontent.com”; var GOOGLE_CLIENT_SECRET =“xxxx”; passport.use(新的GoogleStrategy({ 客户ID:GOOGLE_CLIENT_ID, clientSecret:GOOGLE_CLIENT_SECRET, callbackUrl:“ http://127.0.0.1:3000/auth/google/oauth2callback ”},函数(accessToken,refreshToken,profile,done){done(null,profile); })); 这里的路由是authenticate.js router.get('/ google',passport.authenticate('google',{scope:[' https://www.googleapis.com/auth/plus.login ']}),function(req,res){} ); router.get('/ google / oauth2callback',passport.authenticate('google',{successRedirect:'/ auth / success',failureRedirect:'/ […]

通过云端function访问Gmail API

我正在尝试构build一个响应Gmail邮件发送邮件的电子邮件parsing器。 我目前能够接收和parsingpubsub消息并提取historyId,但我无法validation我的请求到gmail api。 这是我到现在为止: //function defined outside the scope of the main function //used to create auth client function getAuthClient(event, callback) { var GoogleAuth = require('google-auth-library'); var authFactory = new GoogleAuth(); authFactory.getApplicationDefault(function (err, authClient) { if (err) { console.log('Unable to get application default credentials.'); callback(err); return; } // Create the oAuth scopes you need if […]

redirect_uri的参数值无效:Missing scheme:/ auth / google_auth_code / callback

编辑 : 这是一个最小的可行的项目 我正尝试从服务器端stream的授权代码获取来自Google的访问和刷新令牌。 我遵循Google的指南: https : //developers.google.com/identity/sign-in/web/server-side-flow 。 我正在使用护照和护照-Google-authcode 。 以下是节点应用的路由: router.get('/auth/google_auth_code', passport.authenticate('google_authcode', { scope: [ 'https://www.googleapis.com/auth/calendar', 'profile', 'https://www.googleapis.com/auth/userinfo.email' ] }), function () { res.end(); }) router.get('/auth/google_auth_code/callback', passport.authenticate('google_authcode', { failureRedirect: '/error' }), function (req, res) { // do something with req.user res.send('hello'); } ); 这是该策略的护照configuration。 passport.use('google_authcode', new GoogleAuthCodeStrategy({ clientID: 'my client id', clientSecret: 'my […]

使用Android帐户login网站

我正在构build一个响应式Web应用程序。 它使用谷歌oauthlogin,它工作得很好(nodejs与passportjs)。 当从android手机浏览网站,并按下“login”,我得到了谷歌login页面,就像使用桌面时一样。 有没有可能从Android使用谷歌帐户,而不是强迫用户input他的凭据?

Node.js“passport-google-oauth2”在Express应用程序中传递“未能获取用户configuration文件”错误

在开发node.js入门书 (一个使用Google OpenIDauthentication策略的express.js应用程序)的最后一个例子时,在将passport-google包(在2015年4月20日过期)replace为passport-google-oauth2软件包(Google OAuth 2.0authentication策略),并遵循其文档页面上的说明和示例 。 select了oath2.js模块抛出的Google+帐号后,我得到了以下错误,具体调用this._oauth2.get("https://www.googleapis.com/plus/v1/people/me",…)在userProfile(accessToken, done)方法中。 下面是相关的源代码和模块依赖关系。 什么可能是问题的根源? 具体的错误是: InternalOAuthError: failed to fetch user profile at <…>\web-app\b4\node_modules\passport-google-oauth2\lib\oauth2.js:92:28 at passBackControl (<…>\web-app\b4\node_modules\passport-google-oauth2\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:124:9) at IncomingMessage.<anonymous> (<…>\web-app\b4\node_modules\passport-google-oauth2\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:143:7) at IncomingMessage.emit (events.js:129:20) at _stream_readable.js:908:16 at process._tickCallback (node.js:355:11) 相关应用程序的代码是: passport = require('passport'), //… GoogleStrategy = require('passport-google-oauth2').Strategy; // #passport-google-oauth2 //… /***** #passport-google-oauth2 vv *****/ passport.use(new GoogleStrategy({ clientID: "a_specific_value", clientSecret: "another_specific_value", callbackURL: […]