Tag: oauth 2.0

如何在login成功后closureslogin标签?

我在用: MS Bot框架的Node SDK(版本3.7) AuthBot(使用OAuth2) 我已经编码它,所以生成的幻数自动保存,对话会话开始,只要用户通过MS帐户login。 我的问题是:一旦login成功,是否可以closures浏览器窗口的选项卡? 我已经尝试过在各个地方search,并尝试了windows.close()方法,但没有任何工作。 如果没有,是否可以拦截链接(即将在标签中打开)并打开一个本地HTML文件(使用代码: <script> window.close() </script> ),张贴login? 以下是生成JSON响应的代码片段: server.get('/api/OAuthCallback/', passport.authenticate('azuread-openidconnect', { failureRedirect: '/login' }), (req, res) => { console.log('OAuthCallback'); console.log(req); const address = JSON.parse(req.query.state); const magicCode = crypto.randomBytes(4).toString('hex'); const messageData = { magicCode: magicCode, accessToken: req.user.accessToken, refreshToken: req.user.refreshToken, userId: address.user.id, name: req.user.displayName, email: req.user.preferred_username }; magicNum = magicCode; var […]

CORS问题从React应用程序>节点服务器>redirect到Google OAuth2身份validation发出AJAX请求

嗨,我一直在敲我的头研究这个过去2天没有运气。 这是我从React应用程序@localhost:3000尝试使用Google Oauth2 Passport策略进行身份validation时遇到的错误。 我运行一个单独的应用程序与本地主机上的节点/快递服务器:3001。 XMLHttpRequest无法加载http:localhost:3001 / api / auth / google / login。 从“http:localhost:3001 / api / auth / google / login”redirect到“https:accounts.google.com/o/oauth2/v2/auth?response_type = code&redirect_uri = http%3A%2F%2Flocalhost%3A3001%2Fapi %2Fauth%2Fgoogle%2Fcallback&scope = https%3A%2F%2Fmail.google.com&client_id = ***。apps.googleusercontent.com'has been blocked by CORS policy:No'Access-Control-Allow-Origin'header is present on请求的资源。 原因'http:localhost:3000'因此不被允许访问。 createError.js:16 未被捕获(承诺)错误:在XMLHttpRequest.handleError的createError(createError.js:16)处的networking错误(xhr.js:87) 这是在我的客户端使用的代码尝试从我的组件之一login: //button <div> <button className="btn btn-danger" onClick={props.googleAuth}> Login With Google </button> </div> […]

如何仅使用Google云端硬盘的REST API检查访问令牌是否有效?

我在PHP中实现了这个问题的答案,在这个问题上已经转换了代码。 $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, "https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=$access_token" ) ; curl_setopt( $ch, CURLOPT_PORT , 443 ) ; curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ) ; curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ) ; curl_setopt( $ch, CURLOPT_HEADER, false ) ; curl_setopt( $ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded") ) ; $response = curl_exec( $ch ) ; error_log($response); 当我运行代码时,我收到: HTTP/1.1 400 Bad Request Vary: […]

从App中的SSO获取access_token时对OAuth2请求的invalid_grant

我有一个与Uber API集成的iOS应用程序,我使用SSO来validation用户,然后在我的设备上本地保存accessToken&refreshToken。 然后,我打电话给我的服务器,使用javascript后台函数调用节点 – 超级( https://www.npmjs.com/package/node-uber )库来向Uber请求。 到目前为止,我试图用SSOlogin中的2个本地令牌来设置超级客户端,如下所示: var uber = new uberClient({ client_id: '…', client_secret: '…', server_token: '…', name: 'My App', sandbox: true, //optional access_token: accessToken, refresh_token: refreshToken }); 之后我想调用这个uber.requests.getEstimatesAsync端点: uber.requests.getEstimatesAsync({ "start_latitude": pickupLocation["lat"], "start_longitude": pickupLocation["lng"], "end_latitude": dropoffLocation["lat"], "end_longitude": dropoffLocation["lng"] }) .then(function(res) { console.log(JSON.stringify(res)); }) .error(function(err) { console.error(err); }); }) 虽然每次我得到一个“invalid_grant”错误400,而这样做。 我是否犯了一个错误的身份validation错误或设立Uber客户端错误? 是否有可能使用我的SSO accessToken&refreshToken然后在uber客户端,进行OAuth2authentication? 我认为访问和刷新令牌应该和Uber发回给SSO和OAuth2的一样。 […]

如何使用“内容types”:“application / x-www-form-urlencoded”发布Post请求?

我需要在oAuth2身份validation服务器上发出一个请求。 我可以在邮递员的请求中得到令牌,不能从angular度做出同样的要求4。 我的CORSconfiguration良好,因为其他请求正在运行。 这里是HTTP请求的细节。 POST /oauth/token HTTP/1.1 Host: localhost:8080 Authorization: Basic YXBwbGljYXRpb246c2VjcmV0 Content-Type: application/x-www-form-urlencoded Cache-Control: no-cache Postman-Token: 9f9582e9-fe73-499f-d7f7-82498a974e39 grant_type=password&username=pedroetb&password=password 在angular4,我试过这种方式 let headers = new Headers(); headers.append('Content-Type', 'application/x-www-form-urlencoded'); headers.append("Authorization","Basic YXBwbGljYXRpb246c2VjcmV0"); var obtainTokenUrl = 'http://localhost:8080/oauth/token'; this._http.post(obtainTokenUrl + "?grant_type=password&username=pedroetb&password=password", null, {headers: headers}).subscribe(response => { console.log(response); }); 但是这不起作用。 这是邮递员请求标题的屏幕截图: 身体: 那么我怎么能从angular度4做出这个相同的请求呢?

Node.js Passport-Steam:无法发现OP端点URL

你可能会想,这是重复的,但不是。 我正在使用passport.js和Strategy passport-steam(我也试过passport-openid)。 一切工作正常localhost。 我被redirect到Steam并返回,但是当我上传应用程序到远程服务器时,我得到这个错误: Failed to discover OP endpoint URL InternalOpenIDError: Failed to discover OP endpoint URL at /home/cslore.com/nodejs/node_modules/passport-openid/lib/passport-openid/strategy.js:249:52 at /home/cslore.com/nodejs/node_modules/openid/openid.js:787:14 at /home/cslore.com/nodejs/node_modules/openid/openid.js:577:13 at /home/cslore.com/nodejs/node_modules/openid/openid.js:533:11 at Request._callback (/home/cslore.com/nodejs/node_modules/openid/openid.js:226:7) at self.callback (/home/cslore.com/nodejs/node_modules/request/request.js:188:22) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at Request.onRequestError (/home/cslore.com/nodejs/node_modules/request/request.js:884:8) at emitOne (events.js:116:13) 这不仅仅是Steam策略的问题,我尝试了每一个OAuth策略和一些不同的服务(谷歌等),我仍然得到这个错误。 问题在哪里? 为什么护照在本地主机上工作,但在服务器上是这个错误。

Oauth2多个客户端节点js

我正在编写一个服务器oauth2与我的社会node.js使用github示例https://github.com/pedroetb/node-oauth2-server-example 这实际上是工作,但我只是很难知道如何使用多个客户端? 换句话说,model.js中的variablesconfig实际上只有一个客户端的数据,我想使用多个客户端。 先谢谢你,对不起的英语感到抱歉。

在使用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 […]

node.js中的双腿服务器端oauth实现

我有一个node.js API,我想通过双腿OAuth保护。 想知道是否有人知道这个服务器端实现。 请注意,这是用于服务器到服务器的通信,而不是通过第三方服务器提供用户身份validation。

Node.js OAuth2:获取Google+活动

从今天起,我无法通过向此url发送GET请求来检索我的Google+活动: https://www.googleapis.com/plus/v1/people/me/activities/public?key={API_KEY} 我得到一个401错误。 所以我试图使用node.js oauth2库来签署请求,包括预生成的用户令牌,但是我得到了同样的错误。 我的testing脚本的js代码是: var OAuth2 = require('oauth').OAuth2, GOOGLEPLUS_APP_ID = {APP_ID}, GOOGLEPLUS_APP_SECRET = {APP_SECRET}, accessToken = {USER_TOKEN}; var _oauth2 = new OAuth2(GOOGLEPLUS_APP_ID, GOOGLEPLUS_APP_SECRET, '', 'https://accounts.google.com/o/oauth2/auth', 'https://accounts.google.com/o/oauth2/token'); _oauth2.get('https://www.googleapis.com/plus/v1/people/me/activities/public?key={API_KEY}', accessToken, function (err, body, res) { if (err) { console.log('error:'); console.log(err); } else console.log(body); }); 我放置了相同的请求来获取基本的用户信息(url: https : //www.googleapis.com/oauth2/v1/userinfo )并正常工作。 你能帮我一下吗? 谢谢。