我有这个onConnected回调实现Google LocationClient API:
@Override
public void onConnected(Bundle arg0) {
if (lc != null) {
lastKnownLocation = lc.getLastLocation();
LocationRequest request = new LocationRequest();
request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
request.setFastestInterval(MIN_TIME_BETWEEN_LOCATION_UPDATES);
request.setSmallestDisplacement(MIN_DISTANCE_BETWEEN_LOCATION_UPDATES);
lc.requestLocationUpdates(request, ll);
}
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,有时候这一行:
lastKnownLocation = lc.getLastLocation();
Run Code Online (Sandbox Code Playgroud)
给我这个例外:
java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called.
at com.google.android.gms.internal.de.bc()
at com.google.android.gms.internal.ez.a()
at com.google.android.gms.internal.ez$c.bc()
at com.google.android.gms.internal.ey.getLastLocation()
at com.google.android.gms.internal.ez.getLastLocation()
at com.google.android.gms.location.LocationClient.getLastLocation()
at com.citylifeapps.cups.helputils.UserLocation.onConnected(UserLocation.java:115)
at com.google.android.gms.internal.de.aZ()
at com.google.android.gms.internal.de$f.a()
at com.google.android.gms.internal.de$f.a()
at com.google.android.gms.internal.de$b.be()
at com.google.android.gms.internal.de$a.handleMessage()
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356) …Run Code Online (Sandbox Code Playgroud) 我正在根据以下内容通过Google+进行身份验证:https: //developers.google.com/+/mobile/android/sign-in
大多数这个过程似乎很好.我遇到的问题是我们需要获得"一次性授权代码",以便我们的后端服务器可以代表用户在他们的许可下执行某些请求."为您的应用启用服务器端api访问"一节中对此进行了介绍.但是,由于多种原因,即使授权代码有效,我们的服务器也可能导致登录失败(例如,用户在我们的服务器上没有与Google +帐户相对应的帐户,在这种情况下,他们可以制作一).
如果发生这种情况,我们可能需要他们稍后再次登录.但我发现,当我使用google +执行第二次登录时,它会给我相同的授权码,即使它已被我们的服务器使用过.我已经尝试断开连接并重新连接到谷歌客户端API,并打电话GoogleApiClient.clearDefaultAccountAndReconnect(),但无论我做什么,我似乎最终得到相同的授权码.当然,当服务器尝试使用它时,它会被拒绝,因为它已被使用.
我想知道我在这里做错了什么.我有以下方法,在初始身份验证过程中调用,然后再次500从我们的服务器检测到响应状态(表示先前的调用失败,可能是因为代码已被使用):
private void dispatchGooglePlusAuthCodeAcquisition() {
AsyncTask<Void, Void, String> authAcquisition = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
Bundle authPreferences = new Bundle();
mUserPermissionNeededForAuthCode = false;
authPreferences.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES,
"");
String scopesString = Scopes.PROFILE;
WhenIWorkApplication app = (WhenIWorkApplication)WhenIWorkApplication.getInstance();
String serverClientID = app.getGoogleOAuthClientIDForPersonalServer();
String scope = "oauth2:server:client_id:" + serverClientID + ":api_scope:" + scopesString;
String code = null;
authPreferences.putBoolean(GoogleAuthUtil.KEY_SUPPRESS_PROGRESS_SCREEN, true);
try {
code = GoogleAuthUtil.getToken( …Run Code Online (Sandbox Code Playgroud) 根据Google页面中提供的示例,我通过Composer安装了Google Client SDK.并尝试使用以下代码将文件上传到Google云端硬盘:
<?php
header('Content-Type: text/plain');
require_once('vendor/autoload.php');
/**
* Insert new file.
*
* @param Google_Service_Drive $service Drive API service instance.
* @param string $title Title of the file to insert, including the extension.
* @param string $description Description of the file to insert.
* @param string $parentId Parent folder's ID.
* @param string $mimeType MIME type of the file to insert.
* @param string $filename Filename of the file to insert.
* @return Google_Service_Drive_DriveFile The file that …Run Code Online (Sandbox Code Playgroud) 这边的火力地堡文档解释如何检索令牌发出请求到所需的远程配置REST API。
它提供了Python、Java 和 Node.js 的示例代码。因为没有Go 的代码,它把我送到了Google Client Library (for Go)。你也许能理解我为什么迷路了......
这些示例使用GoogleCredential Java中,ServiceAccountCredentials 在Python和google.auth.JWT在Node.js的。我在这里找不到任何这些。我不知道为什么没有明确的命名约定。
firebaseremoteconfig-gen.go:代码看起来已经实现了Firebase 文档页面试图“手动”实现的目标。比较:doc,package。
因为包的“用法示例”结束得奇怪突然,与广泛相反,我不明白如何使用它。
如果有人能告诉我如何使用它,我会得到帮助:
firebaseremoteconfigService, err := firebaseremoteconfig.New(oauthHttpClient)
Run Code Online (Sandbox Code Playgroud)
我不知道我会从哪里来oauthHttpClient。oauth2存储库中有一个包,但我面临同样的问题:
oauth2Service, err := oauth2.New(oauthHttpClient)
Run Code Online (Sandbox Code Playgroud)
我oauthHttpClient再次需要,所以这不能成为解决方案。
http.Client可以是任何东西,但我需要使用service-account.json文件进行身份验证,如此处的三个示例片段所示。
我希望有人有将 …
go google-client firebase google-cloud-platform firebase-remote-config
我愿意在 Google-Cloud-Run 中部署服务。它将是一个(python)Flask 应用程序,将连接到数据存储(数据存储模式下的 firestore)以写入或读取小 blob。
问题是文档中没有解释:访问您的数据库如何在 GCP 内访问数据存储,但不能从 GCE 或 AppEngine 访问数据存储。是否有一种奇特/无缝的方法来实现此目的,或者我应该提供服务帐户凭据,就好像它是外部平台一样?
预先感谢您的帮助和解答。
python-3.x google-client google-cloud-datastore google-cloud-firestore google-cloud-run
我想构建一个应用程序,在用户未登录时代表我的用户管理 Google 日历中的约会。
该应用程序将是一个预订服务,订阅用户(我们的服务提供商)将预订他们不可用的时间,客户将看到服务提供商谷歌日历的忙/闲表示
该应用程序需要能够创建、删除和读取约会。
我已进入 Google Developer's Console 并拥有可弹出 Google 权限屏幕的工作代码,然后重定向到成功创建新约会的 Url。
我可以访问其他日历,但前提是他们当时登录了 Google 服务。
$client = new \Google_Client();
$client->addScope('https://www.googleapis.com/auth/calendar');
$service = new \Google_Service_Calendar($client);
$authUrl = $client->createAuthUrl();
Run Code Online (Sandbox Code Playgroud)
如果用户正在管理他们自己的日历,这可以正常工作。但是,我想代表他们管理约会。这将包括其他各方在日历中输入约会 - 即当日历未登录时。
我需要的是应用程序获得持久访问我用户日历的持久权限吗?
有谁知道这是否可能?关于我如何解决这个问题的想法将不胜感激。
php google-calendar-api google-api zend-framework2 google-client
我正在尝试在我的网站中使用Google Client API在Symfony2中编写谷歌登录.我按照这里的说明进行操作,但是当我调用$ client-> authenticate($ code)时; 命令异常抛出告诉:
无法连接到www.googleapis.com端口443:网络无法访问有
什么问题?
我正在尝试实现一项按自己的节奏消耗 google pubsub 订阅的服务。我的意思是,我需要精细控制何时需要使用消息,即获取一批消息,暂停一段时间,不要获取超过 X 条消息......
使用谷歌客户端库,我没有找到一种方法来做到这一点,因为 MessageReceiver 在它自己的线程中运行,并且我无法控制到底会发生什么。
基本上,能够以同步方式使用消息应该可以解决我的问题。
你知道我如何同步使用谷歌客户端库吗?或者我错过了 API 中的另一种方法?
我正在尝试使用 google-client-api 获取 google-calendar 但遇到以下错误:
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
at java.base/sun.security.ssl.Alert$AlertConsumer.consume(Alert.java:285)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:181)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1362)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1337)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:246)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:113)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1012)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:322)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:346)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:398)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:494)
at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:880)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:541)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:474)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:591)
at org.springframework.batch.core.listener.CompositeJobExecutionListener.beforeJob(CompositeJobExecutionListener.java:73)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:298)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:134)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:127)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) …Run Code Online (Sandbox Code Playgroud) google-calendar-api ssl-certificate google-client tls1.2 java-11
google-client ×10
php ×3
android ×2
firebase ×1
go ×1
google-api ×1
google-cdn ×1
google-login ×1
google-plus ×1
java ×1
java-11 ×1
location ×1
python-3.x ×1
symfony ×1
tls1.2 ×1