使用passport-google-oauth: "0.2.0"在我MEAN堆栈的应用程序(这里找到:https://github.com/jaredhanson/passport-google-oauth).当我运行该应用程序并尝试使用Google API登录时,会返回此错误
- 那是一个错误.
错误:invalid_request
缺少必需参数:redirect_uri
请求详细信息scope = https://www.googleapis.com/auth/plus.login response_type = code redirect_uri = client_id = xxxx-xxxx.apps.googleusercontent.com
重定向参数在这里
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({
clientID:GOOGLE_CLIENT_ID,
clientSecret:GOOGLE_CLIENT_SECRET,
callbackUrl:" http://127.0.0.1:3000/auth/google/oauth2callback "},function(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:'/ auth/failure'}),function(req,res){res.redirect ('/');});
我确信我遗漏了一些简单的东西,但我不知道在这个问题中添加什么会给你最好的信息.请问,我会尽力回答你.这就像是相关数据.
有趣的是,如果我手动添加callbackUrl,那么一切都很好.我可以很好地使用Google API.然后我可以选择"允许"或"拒绝"请求.
在Visual Studio 2017RC中,我创建了具有单个用户帐户的ASP.NET Core MVC应用程序并成功完成了https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins教程以附加Google认证.我现在通过我的Google帐户登录了.
我所做的就是在自动生成的代码中添加几行(在Startup.cs的Configure方法中):
app.UseGoogleAuthentication(new GoogleOptions
{
ClientId = "xxxx.apps.googleusercontent.com",
ClientSecret = "xxxx",
Scope = { "email", "openid" }
});
Run Code Online (Sandbox Code Playgroud)
我现在需要获取由Google发布的访问令牌的价值(并由应用程序存储在cookie中).然后,我将使用它来生成XOAuth2密钥以访问Google服务.例如,在HomeController的About方法(由标准向导自动生成)中,我想显示收件箱中未读电子邮件的数量.使用XOAuth2密钥,我可以登录我的Gmail并从此处继续操作.
我怎样才能得到这个令牌? - 在通过Google初始登录时,是否需要在数据库中存储访问令牌?如果是这样,任何线索如何在标准向导生成的ASP.NET Core MVC应用程序中完成此操作? - 或者,也许我总是可以从cookie中读取访问令牌?如果是这样,怎么样?
最好是,我从cookie中读取它(无论如何),避免在数据库中复制这些信息,但不确定这种方法是否可行(即是否可以解密).
我曾经为ASP.NET MVC做过一次,但是在ASP.NET Core MVC中,事情发生了很大变化,遗留代码已经没用了.
在我的Android应用程序中集成Auth0登录.对于这个集成,我正在关注这个 https://auth0.com/docs/libraries/lock-android
它之前的工作很好,但现在我面对403不允许的用户,而点击谷歌.
当我在谷歌搜索时,我发现这一点:谷歌自4月20日起决定阻止从嵌入式网页浏览访问以达到安全目的,这就是为什么用谷歌登录Auth0失败的原因.
iOS家伙使用以下方法解决了同样的问
但是在android中没有找到这个
如何解决这个问题.任何人都有这个想法.
我的代码:
compile 'com.auth0.android:lock:2.+'
Auth0 auth0 = new Auth0(getString(R.string.auth0_client_id), getString(R.string.auth0_domain));
mLock = Lock.newBuilder(auth0, mCallback)
//Add parameters to the builder
.closable(true)
.build(this);
startActivity(mLock.newIntent(this));
private LockCallback callback = new AuthenticationCallback() {
@Override
public void onAuthentication(Credentials credentials) {
//Authenticated
}
@Override
public void onCanceled() {
//User pressed back
}
@Override
public void onError(LockException error) {
//Exception occurred
}
};
Run Code Online (Sandbox Code Playgroud)
表现:
<activity
android:name="com.auth0.android.lock.LockActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/MyLock.Theme">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data …Run Code Online (Sandbox Code Playgroud) android google-oauth google-oauth2 auth0 auth0-delegated-admin
在网络应用中,我们使用Firebase Auth来管理登录名和(基本)帐户创建。如果在具有多个Google帐户的活跃用户中使用Google登录选项,则会向用户显示Google帐户选择器,以选择要在我们网站上使用的帐户。其标题如下所示:
选择一个帐户
以继续访问mydomain.com
就我的Web应用而言,它没有显示mydomain.com,而是显示了<firebase-project-id> .firebaseapp.com。
我要做的就是更改,以便帐户选择器弹出窗口显示mydomain.com?
web-applications google-oauth2 firebase-authentication angularfire2
我已经在我的Django项目中为Google OAuth2 实现了python-social-auth库,并能够成功使用它登录用户。该库将access_token收到的信息存储在Google OAuth2流的响应中。
我的问题是:使用google-api-python-client似乎依赖于创建和授权credentials对象,然后使用它来构建API,service如下所示:
...
# send user to Google consent URL, get auth_code in response
credentials = flow.step2_exchange(auth_code)
http_auth = credentials.authorize(httplib2.Http())
from apiclient.discovery import build
service = build('gmail', 'v1', http=http_auth)
# use service for API calls...
Run Code Online (Sandbox Code Playgroud)
由于我是从access_tokenpython-social-auth提供的开始,因此如何service为未来的API调用创建和授权API客户端?
编辑:澄清一下,上面的代码来自Google提供的示例。
python oauth2client google-api-python-client python-social-auth google-oauth2
我是android开发的新手。尝试在Android网络视图中集成FB和Google+登录。FB登录正常。但是Google登录名不允许登录。我提到了一些链接,但无法成功。
问题是在Gmail中提供了用户名和密码后,我的网站未登录
Google登录无法正常运行的Android Webview应用
Google登录无法正常运行的Android Webview应用
private class MyCustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
String host = Uri.parse(url).getHost();
Log.d("Loading URL", url);
if (host.equals(target_url_prefix)) {
// This is my web site, so do not override; let my WebView load
// the page
if (mWebviewPop != null) {
mWebviewPop.setVisibility(View.GONE);
mContainer.removeView(mWebviewPop);
mWebviewPop = null;
}
return false;
}
if (host.contains("m.facebook.com") || host.contains("facebook.co")
|| host.contains("google.co")
|| host.contains("www.facebook.com")
|| host.contains(".google.com")
|| host.contains(".google")
|| host.contains("accounts.google.com/signin/oauth/consent")
|| host.contains("accounts.youtube.com")
|| host.contains("accounts.google.com") …Run Code Online (Sandbox Code Playgroud) android ×2
oauth-2.0 ×2
angularfire2 ×1
auth0 ×1
express ×1
google-oauth ×1
java ×1
node.js ×1
oauth2client ×1
python ×1