Tag: google oauth

得到谷歌日历假日nodejs

我想获得谷歌日历假期 此function来自https://developers.google.com/google-apps/calendar/quickstart/nodejs 只用我的calendarID工作……….. function listEvents(auth) { var calendar = google.calendar('v3'); calendar.events.list({ auth: auth, calendarId: 'en.thai#holiday@group.v3.calendar.google.com', timeMin: (new Date()).toISOString(), maxResults: 10, singleEvents: true, orderBy: 'startTime' }, function(err, response) { if (err) { console.log('The API returned an error: ' + err); return; } var events = response.items; if (events.length == 0) { console.log('No upcoming events found.'); } […]

google-oathlogin后挂起的node.js / express /护照

我正在尝试学习node.js,并且在使用google oauth做快速login存储cookie时感到头疼。 我正在使用mongodb,用户得到保存没有问题。 我可以login就好了,但是当我设置cookie baaaam。 但是在控制台上没有错误。 如果我尝试使用Cookie会话设置cookie,并且表示应用程序挂起,我甚至不能访问任何path“/”甚至是“/注销”。 我只能访问他们,如果我清除浏览器上的cookies。 我被困在这一点上。 这是我的app.js app.use( cookieSession({ maxAge: 30 * 24 * 60 * 60 * 1000, keys: [keys.cookieSession] }) ); app.use(passport.initialize()); app.use(passport.session()); 我的路线 app.get('/auth/google', passport.authenticate('google', { scope: ['profile', 'email'] }) ); app.get('/auth/google/callback', passport.authenticate('google')); app.get('/api/logout', (req, res) => { req.logout(); res.send(req.user); }); 和我的passport.js passport.serializeUser((user, done) => { done(null, user.id); }); […]

Google OAuth2.0需要“个人资料”范围吗?

我目前正在尝试允许我的应用程序的用户授权我的应用程序访问他们的Doubleclick for Advertisers API。 我使用Passport.js来处理这个授权。 当我包含这样的configuration文件作用域和DFA作用域时: app.get '/requestAccess', passport.authenticate 'dfa', scope: [ 'https://www.googleapis.com/auth/dfatrafficking', 'profile' ] 这工作正常。 不过,我只关心DFA api,而实际上我并不打算使用configuration文件范围中的任何内容,所以我想删除它: app.get '/requestAccess', passport.authenticate 'dfa', scope: [ 'https://www.googleapis.com/auth/dfatrafficking', ] 当我现在批准使用这条路线时,我得到: "error": { "errors": [ { "domain": "global", "reason": "insufficientPermissions", "message": "Insufficient Permission" } ], "code": 403, "message": "Insufficient Permission" } } 这来自Google,这意味着我要求的范围是不够的。 是否需要configuration文件范围才能进行任何其他访问? 为什么我不能只请求DFA范围?

Google加用户年龄范围使用passport.js

我使用Jared Hanson的OAuthStrategy2( https://github.com/jaredhanson/passport-google-oauth )使用passportjs。 我想获得用户年龄范围在configuration文件对象,但我无法得到它。 即使我在范围内使用https://www.googleapis.com/auth/plus.login,Google保证也会返回年龄范围。 有没有办法通过护照获得这个信息,或者我会被迫做REST请求到谷歌过去的护照? 这是护照与我使用的范围进行身份validation: app.get('/auth/login/google', passport.authenticate('google', { scope: ['https://www.googleapis.com/auth/plus.login', 'https://www.googleapis.com/auth/userinfo.email' ] }), function(req, res) {}); 这是我得到的结果: { provider: 'google', id: '115346138147341087148', displayName: 'Testing Account', name: { familyName: 'Account', givenName: 'Testing' }, emails: [ { value: undefined } ], _raw: '{\n "id": "115346138147341087148",\n "name": "Testing Account",\n "given_name": "Testing",\n "family_name": "Account",\n "link": "https://plus.google.com/115346138147341087148",\n […]

passport-google-oauth2获取节点js中的gmail.users.messages.list

首先,我对护照节点js + oauth2比较陌生,所以如果您有任何困惑,请发表评论。 我已经尝试下面的身份validation谷歌从oauth2与node.js,这里是代码 var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; var google = require('googleapis'); var GOOGLE_CLIENT_ID = "—MY-CLIENT-ID"; var GOOGLE_CLIENT_SECRET = "—MY-CLIENT-SECRET"; var app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.get('/', function(req, res){ res.render('index', { user: req.user }); }); app.get('/account', ensureAuthenticated, function(req, res){ res.render('account', { user: req.user }); }); app.get('/login', function(req, res){ res.render('login', { user: req.user […]

在没有OAuth2redirect/复制和粘贴的情况下访问私有Google云端硬盘数据

我正在开发一个开源的Node模块,需要访问每个用户的私有Google云端硬盘文件。 我一直试图围绕所有这些不同的身份validationtypes,并走到了路障。 从我收集的信息来看,有两种主要的身份validationtypes 作为图书馆作者,我在图书馆中提供了使用OAuth2validation每个用户所需的公钥和私钥。 这意味着给他们一个URL去让我的应用程序访问他们的数据的权限,并让他们复制并粘贴访问码回到他们的terminal。 我能够通过这个教程,并得到它的工作,但这种方法似乎是危险的,因为我必须与我的图书馆打包的密钥,并不必要的困难。 让用户访问Google API控制台,获取他们自己的API密钥,并通过某种configuration文件将其提供给我的库。 没有URLredirect,没有复制和粘贴,只有他们有权访问的一些私人凭据。 2对我来说听起来好多了:这个图书馆一旦拿到用户手里就完全没有用,所以感觉不正确。 但是从我所能find的方面来说,使用Google的API来做到这一点的唯一方法是创build一个Google服务帐户,下载他们提供给您的JSON,通过类似于这篇博文顶部评论的stream程,然后手动给服务帐户电子邮件访问我的个人Google云端硬盘文件。 这看起来很诡异,而且还有很多工作要获得我自己的私人数据。 有没有更好的方法去做这件事? 我觉得这很奇怪,在其他API中这种相当标准的stream程只能通过服务帐户在Google的API中使用,但也许有一种方法,我只是没有看到它。 我是相当新的身份validation,所以任何帮助都是赞赏。 谢谢!

Passport.jslogin事件function没有被调用

我用护照快递使用以下代码: var GAuth = require('passport-google-oauth'); passport.use('google', new GAuth.OAuth2Strategy({ clientID: GID, clientSecret: GSECRET, callbackURL: "http://localhost:3000/auth/google/callback" }, function(accessToken, refreshToken, profile, done){ // not running console.log('callback'); console.log('id: ', profile.id); })); router.get('/google', passport.authenticate('google', { scope: [ 'email', 'profile' ] })); router.get('/google/callback', function(req, res) { // this runs res.send('Logged in through Google!'); }); 即使login似乎在外面工作正常,因为我去到谷歌的权限页面,然后被定向到callback页面。 我不能得到callback函数运行,所以我做错了什么?

使用从客户端接收到的谷歌授权代码在服务器端获取访问令牌javascript(nodejs)

我已经通过这个文档: – https://developers.google.com/identity/sign-in/web/server-side-flow 在最后一步它会收到授权码,然后显示使用java或python库接收访问令牌和刷新令牌的例子,但是我无法在nodejs中find任何类似的例子。 我怎样才能复制使用nodejs相同的例子? 我不能只发送一个post或获得一些谷歌oauth api的请求,并使用授权码接收访问令牌? 提前致谢 :)

passport-google-oauth无法注销用户

我使用passport-google-oauth模块对使用Express.js构build的Web应用程序上的用户进行身份validation。 注销事件是这样处理的: app.get('/logout', function(req, res) { console.log("logged out!"); req.logout(); res.redirect('/'); }); 虽然这确实将用户redirect到login页面(at / ),但我不确定是否真的将他注销。 点击注销后,当我在新选项卡中打开Gmail时,我仍然在那里login(并且没有,我以前没有login过Gmail )。 我怎样才能解决这个问题? 另外, req.logout()做什么来logging用户?

Passport.js:UID是唯一的吗?

我有一个Nodejs应用程序,我使用Passeport让我的用户通过Oauth连接Facebook或Google。 我连接后存储基本数据,如:uid,名字等 我怎么能保证,我收到的用户名将永远是唯一的给定的用户? 我的意思是,数据来自Facebook或Google,所以为什么我不能面对不同用户的讨厌的重复uid?