我目前正在开发一个基于Web的邮件服务(它不是一个邮件客户端,但需要解释很多).但是在此之前我从未使用oauth,但它似乎是要走的路,我已经将我的简单类基于sampel代码.但是,示例代码几次没有提供签名解决方案,或者我错过了它.
所以基本上我的问题是,每当我登录时,我需要再次授权gmail,而我已经看到其他服务你曾经这样做过,之后你只需登录并立即重新定向,而不再接受.
编辑:为了澄清,我正在使用oauth登录和IMAP,这是愚蠢的吗?我认为这是最好的方式,因为当我的所有应用程序真正做到的都是通过oauth围绕谷歌应用程序imap时,将OpenID和oauth连接到同一用户似乎很奇怪.我认为tungle.me以这种方式工作,因为我只需要在那里进行授权,下次谷歌立即重定向我,我希望我的应用程序以这种方式工作.
编辑2:进一步搜索后似乎授权是第一次然后我应该使用身份验证,因为英语不是我的第一语言我虽然他们的意思相同.所以问题就在于,当已经创建帐户的用户再次登录时,如何通过谷歌进行身份验证,这样我就不需要每次都生成新的令牌.
我得到以下内容
{
"error" : "invalid_grant"
}
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:103)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:303)
at com.google.api.client.googleapis.auth.oauth2.GoogleRefreshTokenRequest.execute(GoogleRefreshTokenRequest.java:130)
Run Code Online (Sandbox Code Playgroud)
这只发生在我的生产Appengine实例中(即不在开发服务器上),它只发生在我用于开发和生产测试的电子邮件地址上.
我的工作假设是,它与在dev服务器上被授予刷新令牌的用户有关,这会以某种方式干扰prod服务器上存储的刷新令牌.
任何人都可以确认这个解释,并且有关于如何处理此异常的最佳实践吗?
我试图在ASP.NET MVC 5中使用oauth与Google.
在谷歌的开发者控制台中,我提出了重定向uri:
www.mydomain.com/account/externallogincallback
Run Code Online (Sandbox Code Playgroud)
并认为这样做.但事实并非如此.
我放:
www.mydomain.com/signin-google
Run Code Online (Sandbox Code Playgroud)
它工作了!
我试图在我的项目中搜索字符串"signin-google",但无法在任何地方找到它.
有人能告诉我发生了什么事吗?为什么会这样?谢谢.
我已经在Linux上配置了Google身份验证器,并且我的mfa正常运行,但是根据我的说法,MFA令牌应在30秒后过期,但即使在30秒后,我仍可以使用该令牌。
如果我使用令牌,则该令牌不可重复使用,但如果在30秒钟内不使用它,那么我也可以在一段时间后使用它。这正常吗?我希望我的令牌在30秒内过期,即使我使用或不使用它也是如此。有人可以帮我吗?
我有这个代码,但我在maven-repository中找不到
要导入的正确库.有谁知道它是谁?
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
/** Authorizes the installed application to access user's protected data. */
private static Credential authorize() throws IOException {
dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
// set up authorization code flow
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES).setDataStoreFactory(
dataStoreFactory).build();
// authorize
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
}
Run Code Online (Sandbox Code Playgroud)
我找不到com.google.api.client.extensions.jetty
https://mvnrepository.com/search?q=com.google.api.client.extensions.jetty
我正在集成适用于Android的Google登录,并且希望返回id_token以便可以通过服务器进行身份验证。我按照https://developers.google.com/identity/sign-in/android/backend-auth中的所有步骤进行操作
如果我只是要求,requestEmail()那么我将取回个人资料信息,但是如果我添加的.requestIdToken(getString(R.string.server_client_id))话,result.isSuccess()则为假,并且我没有取回任何帐户信息。有任何想法吗?
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(getString(R.string.server_client_id))
.build();
Run Code Online (Sandbox Code Playgroud)
onActivityResult:
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
String idToken = acct.getIdToken();
mIdTokenTextView.setText("ID Token: " + idToken);
// TODO(user): send token to server and validate server-side
} else {
mIdTokenTextView.setText("ID Token: null");
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试在“结果”上调用任何方法,则会收到Null指针错误...
java.lang.RuntimeException:无法将结果ResultInfo {who = null,request = 9001,result = 0,data = Intent {(has extras)}}传递给活动{com.test.LoginActivity}:java.lang.NullPointerException
场景:
我正在构建一个允许用户使用他们的Google帐户登录的应用,值得注意的是,这是使用Firebase身份验证完成的.
问题:
用户完美地登录,但每当我得到他们的个人资料图片时,它都会很好地返回,但它非常模糊.
我研究并发现一些网站提到改变谷歌个人资料图片的分辨率,但我不确定这是否可行.我知道Facebook有一个图表,允许你操纵配置文件图像的URL来改变分辨率,但我不知道如何通过谷歌提高配置文件图像的分辨率.
我发布了下面模糊图片的截图:
这是我正在加载配置文件图像的ImageView的XML代码:
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/image_view_profile_pic"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="36dp"
android:src="@drawable/app_bar_tool_bar_bg"
app:civ_border_width="2dp"
app:civ_border_color="#FFFFFFFF"
android:contentDescription="@string/content_description_profile_picture" />
Run Code Online (Sandbox Code Playgroud)
这是我用来通过Firebase从Google获取个人资料图片的代码:
private void getUserProfileContent() {
// Check if the user is signed in
if (mUser != null) {
for (UserInfo profile : mUser.getProviderData()) {
// Profile photo url
Uri photoUrl = profile.getPhotoUrl();
// Load user's profile photo from their signed-in provider into the image view
Glide.with(ProfileActivity.this)
.load(photoUrl)
.into(mProfilePic);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是获取当前经过身份验证的用户的代码:
// Variable declaration
private FirebaseUser mUser;
// Initializatioin in …Run Code Online (Sandbox Code Playgroud) android uri google-authentication firebase firebase-authentication
我一直在使用google-auth-library@0.10.0 nodejs来验证我的api服务中的用户身份,现在它已改为1.0,一切都坏了.
我以前用过这里的例子:
https://developers.google.com/identity/sign-in/web/backend-auth
现在我无法弄清楚如何使用新库验证身份.这里的示例:https://github.com/google/google-auth-library-nodejs 解释了如何访问谷歌API,我只需要验证身份.这是我的代码:
const GoogleAuth = require('google-auth-library');
const auth = new GoogleAuth.GoogleAuth();
const google = require('googleapis');
const authData = {
'googleAuth': {
'clientID': 'xxxxxxxxxxx-aaaaaaaaaaaaaaaaaaaaaa.apps.googleusercontent.com',
'clientSecret': 'sssssssssssssssssssssssss',
'callbackURL': 'http://localhost:121212/auth/'
}
};
const CLIENT_ID = authData.googleAuth.clientID;
function verifyToken(token) {
let tokenPromise = new Promise(function(resolve, reject) {
client.verifyIdToken(
token,
CLIENT_ID,
// Or, if multiple clients access the backend:
//[CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3],
function(e, login) {
if (e) {
return reject(e);
} else {
var payload = login.getPayload();
var …Run Code Online (Sandbox Code Playgroud) 我是 Python 新手。我想使用 Google 文本到语音转换 API,因为我在下面的代码中使用了它,但由于错误,我无法访问该 API。这是代码,
def synthesize_text(text):
"""Synthesizes speech from the input string of text."""
from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()
input_text = texttospeech.types.SynthesisInput(text=text)
# Note: the voice can also be specified by name.
# Names of voices can be retrieved with client.list_voices().
voice = texttospeech.types.VoiceSelectionParams(
language_code='en-US',
ssml_gender=texttospeech.enums.SsmlVoiceGender.FEMALE)
audio_config = texttospeech.types.AudioConfig(
audio_encoding=texttospeech.enums.AudioEncoding.MP3)
response = client.synthesize_speech(input_text, voice, audio_config)
# The response's audio_content is binary.
with open('output.mp3', 'wb') as out:
out.write(response.audio_content)
print('Audio content written to file "output.mp3"')
Run Code Online (Sandbox Code Playgroud)
这是错误,
google.auth.exceptions.DefaultCredentialsError: …Run Code Online (Sandbox Code Playgroud) google-api google-authentication python-3.x google-text-to-speech
在此页面https://cloud.google.com/docs/authentication/production 上,有一个指南,其中包含有关如何设置 google API 身份验证的示例。但是,我的 IDE 似乎无法理解或无法找到验证所需的“ToChannelCredentials()”方法。有什么特定的东西我没有导入吗?这是我的代码
using System;
using System.IO;
using Grpc.Core;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.Vision.V1;
namespace ClassLibrary1
{
public class Class1
{
public static void Main(String[] args)
{
var credential = GoogleCredential.FromFile("myPath").CreateScoped(ImageAnnotatorClient.DefaultScopes);
var channel = new Grpc.Core.Channel(ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.;
var client = ImageAnnotatorClient.Create();
var image = Image.FromFile("myImage");
var response = client.DetectLabels(image);
foreach (var annotation in response)
{
if (annotation.Description != null)
{
Console.WriteLine(annotation.Description);
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) android ×2
c# ×2
oauth-2.0 ×2
asp.net-mvc ×1
firebase ×1
google-api ×1
identity ×1
java ×1
maven ×1
node.js ×1
oauth ×1
php ×1
python-3.x ×1
uri ×1