Tag: oauth

与angular和节点的Oauth

我有麻烦得到oauthangular度工作。 当我直接进入链接到浏览器 http://localhost:8080/auth/twiter 我能够使用oauth进行连接,并得到回应但是,当我试图用下面的代码angular度做到这一点 login_twitter : function login_twitter(){ var deferred = $q.defer(); $http.get('auth/twitter') .success(function (data,status){ if(status === 200 && data.state=='success'){ user = data.user.name; defered.resolve(); } else{ deferred.reject(); } }) .error(function (data){ deferred.reject(); }); return deferred.promise; 我从浏览器中得到一个错误 XMLHttpRequest cannot load ….link… No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed […]

Angularjs CORS与Node,Express,Oauth2和Passport有关

最近我们决定把我们的前端从EJS切换到Angular将前端和后端完全分开。 这样做,我们开始在多个浏览器中遇到几个问题。 在后端,我们使用快递的节点与护照和oauth2。 对于前端我们正在尝试使用angular度。 EJS使用express.render工作,但我们更愿意直接使用express作为RESTful API。 我在localhost:8080和localhost:3000本地运行后端和前端。 当只使用后端(使用EJS,而不是angular度),我可以成功地去浏览器的后端端口,通过passport-oauthlogin,并redirect到帐户页面(从供应商login屏幕),我的JSON数据通过res.json呈现。 问题是我无法从移除EJS后从前端用户界面。 我已经试过configurationCORS十几种不同的方式,而使用三种不同的浏览器,没有运气。 以下三个片段是我在浏览器控制台中通过$ http和$ resource从前端访问localhost:8080时出现的错误(请参阅下面的代码)。 三个代码片段下面的图片是节点控制台告诉我,当试图从每个不同的浏览器访问端口8080 … 铬: XMLHttpRequest cannot load 'PROVIDER-DETAILS-URL'. No 'Access-Control-Allow- Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 火狐: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at 'PROVIDER-DETAILS-URL'. (Reason: CORS header […]

LinkedIN OAuthlogin麻烦Nodejs

我正在使用LinkedIn OAuth和护照进行login。无论什么原因,我第一次尝试login时,它会在没有login的情况下路由到主页。然而,第二次login正确。 什么可能导致这个问题? LinkedIn或护照? 这是获取path: router.get('/auth/linkedin/callback', passport.authenticate('linkedin', {failureRedirect: '/', failureFlash:true}), function (req, res, next) { User.findOne({_id: req.user._id}, function (err, user) { if (err) { return next(err); res.redirect("/") } user.last_login = moment(); user.save() return res.redirect('/profile/' + user.username); }); }); 然后护照链接在: passport.use(new LinkedInStrategy({ clientID: config.linkedin.consumerKey, clientSecret: config.linkedin.consumerSecret, callbackURL: config.linkedin.callbackURL, state: true, scope: ['r_basicprofile', 'r_emailaddress']}, function (token, refreshToken, […]

Google云端硬盘API服务帐户域内

我必须使用Node.js服务器从Drive上的文件夹下载/上传/删除文件。 该文件夹位于公司的G Suite中,公司中只有less数人可以访问。 我必须使用服务帐户来执行此操作,问题是:是否有可能? 我怎样才能做到这一点? 我已经阅读https://developers.google.com/drive/v2/web/delegation和https://developers.google.com/identity/protocols/OAuth2ServiceAccount,但我不知道是否有可能授予服务帐户访问公司的域内的文件夹,因为服务帐户是@ developer.gserviceaccount.com和公司的域名是其他,所以当我尝试将该服务帐户添加到该文件夹​​时给我一个错误。 如果你能指导我,我会非常感激。 谢谢!

带有vuejs和nodejs的Google oauth2

我开发一个错误记者应用程序。 整个项目分为两个不同的项目 – 两个都有不同的package.json文件 – 一个用于客户端,我使用Vue.js 2,一个用Nodejs 8和Express.js构build的服务器部分。 这两部分将通过REST API进行通信。 要访问信息中心并报告错误,用户必须login他的Google帐户。 到目前为止,我已经初始化Vuejs中用户将会触发login事件的结构。 我使用a标签,当按下时触发signin()方法:in <a @click="sign">SIGN IN</a> // … export default { methods: { signin() { // start animation let loadingInstance = this.$loading({ fullscreen: true, text: 'Waiting for Google authorization…' }); // opens the Google sign in window // when ready stop the loading loadingInstance.close(); }, […]

Google Cloud PubSub:以前有效的订阅突然未经授权

我在使用Google Cloud PubSub API时遇到了一些麻烦。 最近,我开始使用Cloud PubSub为我正在处理的聊天服务器排队消息。 来自PubSub订阅的消息将被转发给使用socket.io节点库的用户。 我没有问题得到这个设置 – 我运行我的node.js服务器,打开几个浏览器窗口,我可以聊天没有任何问题。 但是,我注意到,经常在服务器运行了几个小时后,它开始吐出下面的错误: (node:2525) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. (node:2525) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Request had invalid authentication credentials. Expected OAuth […]

多个资源服务器的OAuth2stream

正如我试图为内部自定义用户库系统创build一个统一的OAuth2系统一个问题引起我无法find适合的文档: 在我们的微服务应用程序/服务结构中,我们有几个(web)应用程序客户机,它们通常具有单独的应用程序服务器或包含客户机中的所有逻辑。 他们正试图访问微服务networking。 有些API是直接访问的,有些是通过其他服务访问的。 为了保护这些资源,我设想了一个类似于以下的系统: 该图主要面向Node.Js + Passport重型结构,但现实生活中正在使用其他技术。 这里客户端/应用程序服务器将直接使用OAuth2授权服务器来处理完整的login和授权过程。 这将导致客户机/应用程序服务器拥有有效的访问令牌。 使用此访问令牌,然后可以通过在请求的授权标头中将令牌用作承载令牌来访问API。 然后API可以通过validation授权服务器来validation该令牌。 之后,它也可以临时保存令牌,以便不在每个请求上validation令牌,而是使用TTL来存储令牌。 当一个服务在内部访问另一个服务时,它应该只传递Access令牌,以便下一个服务可以再次validation它。 这是这种情况下的首选stream程/设置,还是我在这里犯了一个错误?

如何获得谷歌+用户configuration文件的细节,给出访问令牌和刷新令牌

使用谷歌API function googleLogin(req, res, next) { var google = require('googleapis'); var plus = google.plus('v1'); SCOPES = 'https://mail.google.com'; var OAuth2 = google.auth.OAuth2; var oauth2Client = new OAuth2( '215995260545-6rp2pg69olionsiugudcl4fni3o36ap9.apps.googleusercontent.com', 'xxxxxxxxxxxxxxxxxxxxxxxx', 'https://developers.google.com/oauthplayground' ); oauth2Client.setCredentials({ access_token: req.query.ac_token, refresh_token: req.query.rf_token }); plus.people.get({ userId: 'me', auth: oauth2Client }, function(err, response) { if (err) console.log(err); console.log(response); }); } 当我运行这个代码时,我得到**insufficient permission**的错误。 我错了吗? "code": […]

Node.js EveryAuth获取Google电子邮件地址

我试图检索谷歌电子邮件地址时使用EveryAuth NPM lib进行OAuth2.0调用谷歌。 有没有人设法让电子邮件返回使用EveryAuth? everyauth.google .entryPath('/auth/google') .callbackPath('/auth/google/callback') .appId('216450162097.apps.googleusercontent.com') .appSecret('8b6yf2nznWHgAu7iKNyGn-0F') .scope(['https://www.googleapis.com/auth/userinfo.email']) .findOrCreateUser( function(session, userAttributes) { console.log(userAttributes); }) .redirectPath('/'); 范围: https : //www.googleapis.com/auth/userinfo.email导致exception: 错误:Error 401(Not Found)!! 1 display:block; height:55px; margin:0 0 -7px; width:150px} *> #g {margin-left:-2px} #g img {visibility:hidden} * html #g img {visibility:visible} * + html #g img {visibility:visible} 那是一个错误。 请求中有错误。 我们知道的就这些。 在EventEmitter的[object Object] .fail(/Users/thegoleffect/Documents/Projects/Spoondate/nitrous/node_modules/everyauth/lib/promise.js:50:15)。 (/Users/thegoleffect/Documents/Projects/Spoondate/nitrous/node_modules/everyauth/lib/modules/google.js:58:15)EventEmitter.emit(events.js:67:17)在EventEmitter._respond(/ […]

Tumblr API – 如何使用NodeJS获取私人博客的post?

我得到一个名为“tumblrwks”( https://github.com/arkxu/tumblrwks )的库,它使用nodejs连接到tumblr API,我工作,但问题是我想让他们形成一个私人博客,为此我需要OAuth请求。 我怎样才能得到Tumblr的OAuth(oauth_token&oauth_secret)? 这是我想用OAuth完成的代码,请帮助我 var Tumblr = require('tumblrwks'); /* You can get the consumerKey and consumerSecret by registing a tumblr app: http://www.tumblr.com/oauth/apps */ var tumblr = new Tumblr( { consumerKey: 'YOUR_CONSUMER_KEY', consumerSecret: 'YOUR_CONSUMER_SECRET', accessToken: 'ACCESS_TOKEN', accessSecret: 'ACCESS_SECRET' }, "void2012.tumblr.com" // specify the blog url now or the time you want to use ); […]