标签: oauth

如何限制到特定域以使用 Spring-Boot 和 OAuth2 登录

我已经使用 spring boot 和 Google 成功完成了 OAuth2 登录,但我想将登录限制在特定域(我们使用的是 Google Apps for Work)。

我认为我应该通过扩展类 OAuth2ClientAuthenticationProcessingFilter (如本线程中所指定)来处理,但我不确定如何做到这一点。

基本上,我想使用 Google OAuth 2.0 作为身份提供者,但必须只接受公司用户 (@company.com)。

java spring oauth spring-boot

0
推荐指数
1
解决办法
5042
查看次数

如何使用OAuth2创建用户?

我使用的DjangoTastypie库和Django的OAuth的工具包,以及用于Django的OAuth的工具包Tastypie认证.

免责声明:我有可能完全错误.如果是这样,请纠正我,引导我走向不那么无知的人.

主要问题:如何安全地创建用户?

我的理解:

  • 为了get或者post,客户端需要一个令牌.
  • 为了获得令牌,他们需要登录.
  • 要登录,他们需要一个用户帐户.
  • 为了创建帐户,他们需要令牌.
  • 要创建帐户,他们需要登录?

我正在努力解决这个问题.当客户端尝试创建不需要OAuth2的帐户时,我会创建吗?或者有没有办法在没有登录的情况下使用OAuth2,只允许客户创建帐户?

任何帮助深表感谢!

api django oauth oauth-2.0 tastypie

0
推荐指数
2
解决办法
1209
查看次数

Facebook xhr登录:跨域请求被阻止

我有这个问题,当我尝试使用XHR通过Facebook登录我的网站上的用户时,我的请求被阻止了,但是,如果我复制XHR请求的URL并将其粘贴到浏览器中,就可以登录。

因此,这是一个简单的示意图:

在此处输入图片说明

为什么XHR被阻止在浏览器可以访问的相同URL上?

javascript facebook oauth xmlhttprequest cors

0
推荐指数
1
解决办法
1271
查看次数

当我尝试在节点中执行 https 发布请求时,出现 getaddrinfo ENOTFOUND 错误

完整的错误是这样的:

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND https://api.instagram.com https://api.instagram.com:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
Run Code Online (Sandbox Code Playgroud)

我得到错误的代码是这样的:

var express = require('express');
var app = express();
var https = require('https');

app.get('/oauth/ig', function (req, res) {
  var options = {
    hostname: 'https://api.instagram.com',
    path: '/oauth/access_token?client_secret=myClientSecret&grant_type=authorization_code&redirect_uri=http://localhost:1992/oauth/ig&code='+req.query.code,
    method: 'POST',
  };
  var igRequest = https.request(options, (response) => {
    res.send("response");
  });
})
Run Code Online (Sandbox Code Playgroud)

我正在使用 nodejs 并且正在尝试进行 Instagram OAUTH。

https oauth node.js instagram

0
推荐指数
1
解决办法
3466
查看次数

Python:从 YouTube 下载字幕

您好,我尝试使用 YouTube 数据 API 从 YouTube 视频下载字幕。我自定义YouTube 生成的示例代码

    #!/usr/bin/python
    # Usage example:
    # python captions.py --videoid='<video_id>' --name='<name>' --file='<file>' --language='<language>' --action='action'

    import httplib2
    import os
    import sys

    from apiclient.discovery import build_from_document
    from apiclient.errors import HttpError
    from oauth2client.client import flow_from_clientsecrets
    from oauth2client.file import Storage
    from oauth2client.tools import argparser, run_flow


    # The CLIENT_SECRETS_FILE variable specifies the name of a file that contains

    # the OAuth 2.0 information for this application, including its client_id and
    # client_secret. You can acquire …
Run Code Online (Sandbox Code Playgroud)

python youtube oauth youtube-data-api

0
推荐指数
1
解决办法
4395
查看次数

Laravel Passport-使用邮递员进行身份验证

我在Laravel 5中设置了Passport,并在用户使用此注册时创建了令牌。

$user->createToken('My Token')->accessToken;
Run Code Online (Sandbox Code Playgroud)

当我创建一个新用户时,我可以在oauth_access_tokens表中看到一个看起来像这样的条目,我缩短了显示的ID ...

id     | user_id | client_id | name     | scopes | revoked
-----------------------------------------------------------
765765 | 193     | 1         | My Token | []     | 0
Run Code Online (Sandbox Code Playgroud)

我想允许访问的API路由受到保护,现在我试图通过在邮递员中传递以下标头来允许访问...

Authorization | Bearer 765765
Accept        | application/json
Run Code Online (Sandbox Code Playgroud)

但这返回未经身份验证的响应,我在哪里出错?

oauth laravel postman

0
推荐指数
1
解决办法
4258
查看次数

用户未经授权时Laravel护照自定义错误消息和状态代码

我的项目正在运行Laravel 5.4,我通常使用passportapi通过api进行身份验证bearer token。一切正常,但是当未经授权的用户尝试访问需要身份验证的资源时,该用户会收到错误消息405 method not allowed 在此处输入图片说明

但我希望得到回应401 unauthorized。如何更改此设置,仅发送带有消息的响应,而不发送异常?我做了调查,但没有发现任何东西。我使用标准laravel中间件授权auth:api。我的路线归入中间件

Route::group(['middleware' => 'auth:api'], function () {
  // these routes should return 401 if user not authenticated
}
Run Code Online (Sandbox Code Playgroud)

authentication oauth laravel laravel-5 laravel-passport

0
推荐指数
1
解决办法
3814
查看次数

Angular/Express/Passport - 使用Google进行身份验证:没有'Access-Control-Allow-Origin

上下文

我正在使用Angular,Express和PassportJS 构建无状态应用程序,并希望使用他们的Google帐户对用户进行身份验证.在对用户进行身份验证后,我的目标是使用JWT令牌来拥有无状态应用程序.

角2侧

点击Google登录按钮后,我的服务中会执行以下代码:

login() {
    return this.http.get('http://localhost:3000/api/auth/google');
}
Run Code Online (Sandbox Code Playgroud)

表达方面

在Express上,执行以下操作:

// This gets executed first after clicking the sign in using Google button.
router.get('/api/auth/google', passport.authenticate('google', {
    session: false,
    scope: ['profile', 'email']
}));

// Google sends me back here (callback).
passport.use(new GoogleStrategy({
        clientID: 'omitted',
        clientSecret: 'omitted',
        callbackURL: '/api/auth/google/callback'
    }, function (accessToken, refreshToken, profile, cb) {

        // Here, I obtain the profile and create a JWT token which I send back to the user.
        let jwtToken = generateToken(); …
Run Code Online (Sandbox Code Playgroud)

oauth cors express passport.js angular

0
推荐指数
1
解决办法
856
查看次数

hwi oauth软件包和Symfony 4.2:无法安装

我正在尝试使用symfony 4.2安装HWI oauth捆绑软件,但是它不起作用。我按照描述的步骤进行操作:https : //github.com/hwi/HWIOAuthBundle/blob/master/Resources/doc/1-setting_up_the_bundle.md但它不起作用。

在作曲家的输出下面:

composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
Using version ^0.6.3 for hwi/oauth-bundle
Using version ^2.0 for php-http/guzzle6-adapter
Using version ^1.14 for php-http/httplug-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.2.*"
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install hwi/oauth-bundle 0.6.3
    - php-http/client-common v1.6.0 requires symfony/options-resolver ^2.6 || ^3.0 -> no matching …
Run Code Online (Sandbox Code Playgroud)

oauth symfony composer-php symfony4

0
推荐指数
1
解决办法
1332
查看次数

如何检查用户是来宾还是在laravel API上登录

Auth()->check()不断返回假。该api仅具有api中间件,我希望访客和登录用户都可以使用它。

我尝试从请求标头中获取授权令牌,但是我不知道有什么方法可以检查哪个用户拥有此令牌。

if(Auth()->check()){
        //return extra data
} else {
        //return something else
}
Run Code Online (Sandbox Code Playgroud)

Auth()->check()即使标头中包含Ive承载令牌,为什么总是返回false?如果标头具有令牌,则应返回true

php oauth laravel laravel-5 laravel-passport

0
推荐指数
1
解决办法
184
查看次数