标签: google-api-client

在连接函数调用后,GoogleApiClient正在抛出"GoogleApiClient尚未连接"

所以我找到了关于GoogleApiClient的一些不太清楚的东西. GoogleApiClient有一个名为onConnected的函数,它在客户端连接时运行(肯定)

我得到了自己的函数:startLocationListening,最终在GoogleApiClient的onConnected函数上调用.

所以我的startLocationListening函数无法在没有GoogleApiClient连接的情况下运行.

代码和日志:

@Override
public void onConnected(Bundle bundle) {
    log("Google_Api_Client:connected.");
    initLocationRequest();
    startLocationListening(); //Exception caught inside this function
}
Run Code Online (Sandbox Code Playgroud)

...

private void startLocationListening() {
    log("Starting_location_listening:now");

    //Exception caught here below:
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
   }
Run Code Online (Sandbox Code Playgroud)

例外是:

03-30 12:23:28.947: E/AndroidRuntime(4936):     java.lang.IllegalStateException: GoogleApiClient is not connected yet.
03-30 12:23:28.947: E/AndroidRuntime(4936):     at com.google.android.gms.internal.jx.a(Unknown Source)
03-30 12:23:28.947: E/AndroidRuntime(4936):     at com.google.android.gms.common.api.c.b(Unknown Source)
03-30 12:23:28.947: E/AndroidRuntime(4936):     at com.google.android.gms.internal.nf.requestLocationUpdates(Unknown Source)
03-30 12:23:28.947: E/AndroidRuntime(4936):     at hu.company.testproject.service.GpsService.startLocationListening(GpsService.java:169)
03-30 12:23:28.947: E/AndroidRuntime(4936): …
Run Code Online (Sandbox Code Playgroud)

android google-api-client google-play-services android-googleapiclient

74
推荐指数
1
解决办法
5万
查看次数

使用Postman访问OAuth 2.0 Google API

我正在尝试使用Postman Chrome应用程序访问Proximity Google API.我已经关注邮递员和谷歌开发网站的教程,但我仍然收到401错误消息.

我在做什么?

  • 第1步 - 启用Proximity API:

In order to use Proximity API, it has to be first enabled in Google Dev console. Using this tutorial I have enabled support for Proximity API for my project

  • Step 2 - Get the credentials:

According to this tutorial, I need to get client ID and secret. This is where I am confused. Credentials->Add credentials->OAuth2.0 client ID->select Chrome App radio button (since I am using Postman)->enter last …

google-api oauth-2.0 google-api-client postman google-oauth2

56
推荐指数
6
解决办法
12万
查看次数

Google OAuth 2.0 失败并出现错误 400:某些 client_id 的 invalid_request,但对于同一项目中的其他人来说效果很好

我们有一些应用程序(或者也许我们应该称它们为一些脚本)使用 Google API 来促进一些管理任务。最近,在同一项目中创建另一个 client_id 后,我开始收到一条错误消息,类似于localhost redirect_uri does not work for Google Oauth2 (results in 400: invalid_request error)中描述的错误消息。IE,

\n
\n

错误 400:无效的请求

\n

您无法登录此应用,因为它不符合 Google\nOAuth 2.0 确保应用安全的政策。

\n

您可以让应用开发者知道此应用不符合\n一个或多个 Google 验证规则。

\n

请求详情:

\n

此部分中的内容由应用开发者提供。\n此内容未经 Google 审核或验证。

\n

如果您\xe2\x80\x99是应用开发者,请确保这些请求详细信息\n符合 Google 政策。

\n

重定向_uri:瓮:ietf:wg:oauth:2.0:oob

\n
\n

我该如何解决这个错误?需要注意的是:

\n
    \n
  • 该项目的 OAuth 同意屏幕标记为“内部”。因此,任何提及 Google 对该项目的审查或发布状态的内容都是无关紧要的
  • \n
  • 我确实为该域启用了“信任内部、域拥有的应用程序”
  • \n
  • 同一项目中的另一个客户端 ID 有效,并且客户端 ID 之间没有明显差异 - 它们都是“桌面”类型,只提供了不同的客户端 ID 和客户端密钥
  • \n
  • 这是一个命令行脚本,因此我使用此处记录的“复制/粘贴”验证方法,因此使用urn:ietf:wg:oauth:2.0:oob重定向 URI(复制/粘贴是在没有浏览器的无头计算机上运行此脚本的唯一友好方法)。
  • \n
  • 我能够在开发域中重现相同的问题。我有三个客户 ID。最旧的一个是 2021 年 1 …

google-api oauth-2.0 google-api-client google-oauth

54
推荐指数
4
解决办法
11万
查看次数

错误:"用于调用Google Play Developer API的项目ID尚未在Google Play开发者控制台中关联."

使用服务帐户访问Google Play Developer API时出现以下错误:

用于调用Google Play Developer API的项目ID尚未在Google Play开发者控制台中进行链接.

服务帐户电子邮件和.p12文件是使用服务帐户选项生成的APIs&Auth -> Credentials.Google Play Developer API中的应用程序使用google文档中提到的项目ID链接到项目.

但是,当我尝试使用Publishing API时,我仍然收到此错误.我正在寻找这个错误的解决方案以及使用Google Publishing API为Java客户端使用Google Play Developer API发布APK的一步一步的流程.我在用androidpublisher_v2_public.

google-api google-api-java-client google-api-client

53
推荐指数
3
解决办法
3万
查看次数

无法处理文件 - Android studio(app:mergeDebugResources)

我是currentyl试图实现Google ActivityRecognitionApi.但是我得到以下错误:

错误:无法处理文件C:\ Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\explosion-aar\com.google.android.gms\play-services-cast -framework\10.0.1\res\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png进入C:\ Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\res\merged \调试\绘制-xxhdpi-V4\quantum_ic_forward_30_grey600_36.png

错误:任务':app:mergeDebugResources'的执行失败.错误:无法处理文件C:\ Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\explosion-aar\com.google.android.gms\play-services-cast -framework\10.0.1\res\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png进入C:\ Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\res\merged \调试\绘制-xxhdpi-V4\quantum_ic_forward_30_grey600_36.png

我是Android开发的新手,真的不知道该怎么做.

我感谢任何评论.

提前致谢

编辑:我的错!忘了复制一些文件......

java android google-api google-api-client activity-recognition

43
推荐指数
4
解决办法
3万
查看次数

GoogleApiClient onConnected从未调用过可穿戴设备

我有一个可穿戴设备,我正在尝试连接到GoogleApiClient,但从不调用回调(onConnected,onConnectionSuspended或onConnectionFailed).其他所有工作正常,DataLayerListenerService能够从掌上电脑接收消息,并在连接时调用onPeerConnected.我试过了仿真器和三星Gear Live设备.这是我在Activity中的代码,我正在尝试连接到GoogleApiClient.

public class WearReaderActivity extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
    public static final String CONTENT_EXTRA = "contentExtra";
    private String LOG_TAG = WearReaderActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.reader);
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Wearable.API)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
    }

    private GoogleApiClient mGoogleApiClient;

    @Override
    protected void onStart() {
        super.onStart();
        Log.e("Connected?", String.valueOf(mGoogleApiClient.isConnected()));
        //new Thread(new GetContent()).start();
    }

    @Override
    public void onConnected(Bundle bundle) {
        Log.d("Connected", "Connected");
        new Thread(new GetContent()).start();
    }

    @Override
    public void onConnectionSuspended(int i) {
        Log.d("Connection suspened", "Connection suspended");
    }

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

android google-api-client wear-os

40
推荐指数
1
解决办法
2万
查看次数

Google电子表格API,400错误错误请求:无法解析范围

我正在尝试使用电子表格示例访问Google电子表格.当我运行示例代码时,它工作正常.我只是改变了SpreadsheetId和范围.它开始给我:

Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Unable to parse range: Class Data!A2:A4",
    "reason" : "badRequest"
  } ],
  "message" : "Unable to parse range: Class Data!A2:A4",
  "status" : "INVALID_ARGUMENT"
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1065)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
    at poc.mainPOC.main(mainPOC.java:157)
Run Code Online (Sandbox Code Playgroud)

以下是代码:

  String spreadsheetId = "my spread sheet ID";
    String range = "Class Data!A2:A4";
    ValueRange response …
Run Code Online (Sandbox Code Playgroud)

java google-sheets google-api-client

40
推荐指数
3
解决办法
2万
查看次数

Google AnalyticsAPI:"用户对此帐户没有足够的权限."

我正在编写一个访问Google AnalyticsAPI的Ruby应用程序来提取一些实验信息.

该应用通过以下功能使用Google服务帐户进行连接和身份验证:

def connect
  ...
  @@client = Google::APIClient.new(:application_name => 'My Service App', 
                                    :application_version => '1.0.0')
  key_file = Rails.root.join('config', 'privatekey.p12').to_s
  key_secret = 'somesecret'
  key = Google::APIClient::PKCS12.load_key(key_file, key_secret)
  asserter = Google::APIClient::JWTAsserter.new(
    SECRETS[:google_service_account_email],
    ['https://www.googleapis.com/auth/yt-analytics.readonly',
     'https://www.googleapis.com/auth/analytics.readonly'
    ],
    key
  )
  @@client.authorization = asserter.authorize()
  ...
end
Run Code Online (Sandbox Code Playgroud)

...对API进行身份验证和发现,没有问题.

针对YouTube Analytics API使用客户端可以正常运行.使用相同的帐户通过...访问Analytics API

response = @@client.execute({
  # 'analytics is the API object retrieved via discover_api()
  :api_method => analytics.management.experiments.list, 
  :parameters => {
    'accountId' => 'AAAAAAAA',
    'profileId' => 'PPPPPPPP',
    'webPropertyId' => 'UA-WWWWWWWW-#'
  }
})
Run Code Online (Sandbox Code Playgroud)

结果出现403错误响应:

{"domain":"global","reason":"insufficientPermissions","message":"User does not have …
Run Code Online (Sandbox Code Playgroud)

google-analytics google-api google-analytics-api google-api-client

35
推荐指数
2
解决办法
5万
查看次数

在为Android开发实施GoogleApiClient Builder时出错

我正在关注Google的文档,以便在应用中实施Google+登录功能.

https://developers.google.com/+/mobile/android/getting-started

我按照指南跟踪了每一步,但卡在了由GoogleApiClient.Builder生成的错误中,我彻底搜索但没有得到任何结果.请帮我解决一下.谢谢.

错误代码:

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API, null)
            .addScope(Plus.SCOPE_PLUS_LOGIN).build();
Run Code Online (Sandbox Code Playgroud)

错误信息 :

   The method addConnectionCallbacks(GoogleApiClient.ConnectionCallbacks) in the type 
   GoogleApiClient.Builder is not applicable for the arguments (MainActivity)
Run Code Online (Sandbox Code Playgroud)

完整的MainActivity.java代码:

    package mad.project.mightysatta;

    import android.content.Intent;
    import android.content.IntentSender.SendIntentException;
    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.support.v7.app.ActionBarActivity;
    import android.view.LayoutInflater;
    import android.view.Menu;
    import android.view.MenuInflater;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.ViewGroup;

    import com.google.android.gms.common.ConnectionResult;
    import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
    import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
    import com.google.android.gms.common.api.GoogleApiClient;
    import com.google.android.gms.plus.Plus;

    public class MainActivity extends ActionBarActivity implements
    ConnectionCallbacks, OnConnectionFailedListener {

/* Request code used to invoke sign in …
Run Code Online (Sandbox Code Playgroud)

android google-api-client

34
推荐指数
2
解决办法
6万
查看次数

如何通过API向Google云端硬盘添加/创建/插入文件?

需要有关通过api将文件插入谷歌驱动器的帮助.用于此目的的api文档没有清楚地解释如何通过http post请求发送文件的实际主体.

google-api google-api-client google-drive-api

32
推荐指数
3
解决办法
7万
查看次数