标签: google-api

如何使用Javascript从Google Api检索服务帐户OAuth2令牌?

我需要使用Google Project服务帐户来使用JavaScript访问Google API。为了做到这一点,我需要对Google API服务器进行OAuth2认证。

我知道Google提供了可在节点服务器上使用的库(GAPI),但是我需要一个可以在其他安全JavaScript环境中使用的解决方案。

javascript google-api service-accounts google-oauth2

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

为什么API Explorer中没有Datastore Admin API导出/导入?

有谁知道为什么数据存储区管理API exportimport操作不适用于API资源管理器?

只需访问API页面即可.

同时为获得长期运行操作的API 可用.

初始化API Explorer时出错

google-api google-cloud-datastore google-apis-explorer

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

将dart和flutter与Google Calendar API结合使用以获取用户日历上的事件列表

我正在尝试通过重新构建以前用Java编写的应用程序来学习如何使用飞镖和颤动,这涉及到使用Google自己的Calendar API从Google Calendar获取事件。

通过阅读(不是很详细的)有关googleapis_auth包的文档,以及StackOverflow上唯一的一个非常类似的问题的线程,我已经设法将理论上可行的代码组合在一起:

import 'package:googleapis/calendar/v3.dart';
import 'package:googleapis_auth/auth_io.dart';

//get Service Account Credentials
final accountCredentials = new ServiceAccountCredentials.fromJson({
  "private_key_id": "myprivatekeyid",
  "private_key": "myprivatekey",
  "client_email": "myclientemail",
  "client_id": "myclientid",
  "type": "service_account"
});
var _scopes = [CalendarApi.CalendarScope]; //defines the scopes for the calendar api

void getCalendarEvents() { 
    clientViaServiceAccount(accountCredentials, _scopes).then((client) {
      var calendar = new CalendarApi(client);
      var calEvents = calendar.events.list("primary");
      calEvents.then((Events events) {
        events.items.forEach((Event event) {print(event.summary);});
      });
    });
}
Run Code Online (Sandbox Code Playgroud)

上面的代码在模拟器上运行时不会产生任何错误,也不会在控制台中打印任何事件摘要。但是,当在项目的仪表板上查看时,请求将以成功响应200响应。我还尝试过使用嵌套在clientViaServiceAccount中的类似代码来获取我所有日历的ID,并且它也不会返回任何内容。

另外,从文档中,我发现访问API的最简单方法是通过客户端服务帐户(如代码所示),而不是通过OAuth2客户端ID(我更习惯了)。

我想念什么吗?代码是否错误?也许我需要弄乱服务帐户上的设置?任何帮助,将不胜感激。

google-calendar-api google-api dart flutter

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

Google财经API出错

我想使用谷歌财务api转换货币.但它不在我的本地机器(印度)工作.当我从位于美国的一台服务器点击并提供正确的结果时,它工作正常.

网址:https://finance.google.com/finance/converter?a = 1& from = ZAR & to = USD & meta = 53336452-3e60-4fa1-9740-9ef8ea9e9118

谁能帮助我在我的本地机器上正确地使用这个api?

任何帮助将受到赞赏谢谢.

google-api google-finance currency-exchange-rates

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

ActivityTransitionRequest中指定的无效活动

我正在尝试使用ActivityRecognition。但是,当我尝试获取DetectedActivity.TILTING或DetectedActivity.UNKNOWN的过渡更新时,出现错误。对于所有其他活动类型,我都没有问题。

这是我创建ActivityTransitionRequest的代码

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = new Intent(this, ActivityRecognizedService.class);
    PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0);

    Task<Void> task =
            ActivityRecognition.getClient(this).
                    requestActivityTransitionUpdates(createTransitionsRequest(), pendingIntent);

    task.addOnSuccessListener(
            new OnSuccessListener<Void>() {
                @Override
                public void onSuccess(Void result) {
                    Log.d(TAG, "success");
                    // Handle success
                }
            }
    );

    task.addOnFailureListener(
            new OnFailureListener() {
                @Override
                public void onFailure(Exception e) {
                    Log.d(TAG, "failure", e);
                    // Handle error
                }
            }
    );

    // ActivityRecognition.getClient(this).requestActivityUpdates(1000L, pendingIntent);
}

private ActivityTransitionRequest createTransitionsRequest() {
    List<ActivityTransition> transitions = new ArrayList<>();

    transitions.add( …
Run Code Online (Sandbox Code Playgroud)

android google-api android-pendingintent activity-recognition android-securityexception

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

无法访问Google日历api的googleapis auth.OAuth2

下面的代码是从Google日历Api部分的node.js快速入门中粘贴的。此代码无法从google API的auth中访问。我复制了以下错误。要查看完整的代码,您可以访问此链接。谢谢。

const google = require('googleapis');
const OAuth2Client = google.auth.OAuth2;
Run Code Online (Sandbox Code Playgroud)

错误看起来像这样:

const OAuth2Client = google.auth.OAuth2; ^
TypeError:无法读取未定义的属性“ OAuth2”

google-calendar-api google-api node.js node-modules

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

如何在闪亮的R应用程序中实现Google身份验证?

我想为闪亮的应用程序提供基本身份验证,理想情况下,我不想处理登录协议或密码管理。我希望我的应用提供公开的数据视图,但是如果用户进行了身份验证,则可以使用个性化数据集。在最好的情况下,我想使用联合登录(例如Google)。

一种解决方案是使用代理(auth0shinyProxy)。这是一个重量级的解决方案,需要运行其他服务。另外,没有简单的方法可以将用户登录信息与闪亮的服务器进行通信,这是我的主要目标。并且代理不允许该应用在我要求的非身份验证模式下运行。

另一种解决方案是使用javascript手工制作相对简单的用户名/密码界面。这是一个例子。但是我宁愿不手动管理用户名/密码验证。在我的应用程序中,我希望任何人都可以使用该应用程序,但是我只需要为每个用户提供唯一的ID,即可获得个性化的体验。

因此,如果我想使用Google的身份验证,那么第三种方法是使用GoogleAuthR。但是我发现该库存在问题,因为我无法使其支持持久登录。像其他使用联合登录的应用程序一样,我希望用户稍后返回该URL并仍然保持连接状态。

r google-api google-oauth shiny

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

Google Maps Geolocation不征求许可

我正在尝试在以下页面中使用Google Maps API:https//developers.google.com/maps/documentation/javascript/geolocation

我要做的就是将代码复制到该页面上并将其粘贴到我网站上的测试页面上。 http://kwt-events-com.stackstaging.com/content/api/maps.php

我有一个API密钥。我用了它,页面在google map上加载的很好。

问题是它无法检测到显示此错误的位置:“错误:地理位置服务失败”

我尝试过的允许在浏览器和计算机中进行位置检测。我在同一台机器“ macos”上尝试了不同的浏览器。我在另一台计算机“另一台PC和另一台Mac”上尝试过。我在电话“ ios”上尝试过。

同样的错误

我知道我无法发布所有代码,但是病了,所以你们可以帮助我

<!DOCTYPE html>
<html>
<head>
<title>Geolocation</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
  /* Always set the map height explicitly to define the size of the div
   * element that contains the map. */
  #map {
    height: 100%;
  }
  /* Optional: Makes the sample page fill the window. */
  html, body {
    height: 100%;
    margin: 0;
    padding: 0;
  }
 </style>
 </head> …
Run Code Online (Sandbox Code Playgroud)

html php api google-api google-geolocation

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

Googe Maps:无法读取未定义的属性'setDirections'

我是使用Google Maps API的初学者,我只想在下面的错误方面提供一些帮助:

Uncaught TypeError: Cannot read property 'setDirections' of undefined
at eval (google-maps.vue?1cba:101)
at directions.js:8
at gm.j (directions.js:5)
at Object.c [as _3lwmum] (common.js:46)
at VM1924 DirectionsService.Route:1
Run Code Online (Sandbox Code Playgroud)

这是我实现Directions API的代码

getRoute() {
  this.directionsService = new google.maps.DirectionsService()
  this.directionsDisplay = new google.maps.DirectionsRenderer()
  this.directionsDisplay.setMap(this.$refs.googleMap.$mapObject)
  this.directionsService.route({
    origin: this.location.position,
    destination: { lat: 62, lng: 15 },
    travelMode: 'DRIVING'
  }, function (response, status) {
    if (status === 'OK') {
      this.directionsDisplay.setDirections(response)
    } else {
      console.log('Directions request failed due to ' + status)
    }
  })
},
Run Code Online (Sandbox Code Playgroud)

这就是'this.$ refs.googleMap.$ mapObject'的值

这个.$ refs.googleMap.$ mapObject值

google-maps google-api directions vue.js vuejs2

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

为什么我的Google Analytics(分析)API 4返回错误

您好,我正在使用PHP和Google Client API进行一个小项目。我不知道为什么会收到此错误消息:

消息:未定义的属性:Google_Service_Analytics :: $ reports

因为我的代码正确,所以与Google文档网页上的代码相同。

这是我的代码:

$client = new Google_Client();
    $client->setApplicationName("Hello Analytics Reporting");
    $client->setAuthConfig(FCPATH.'trim-tide-225210-c7xxxxssz7f4c.json');
    $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
    $analytics = new Google_Service_Analytics($client);
    $VIEW_ID = "ga:159882843";

      // Create the DateRange object.
      $dateRange = new Google_Service_AnalyticsReporting_DateRange();
      $dateRange->setStartDate("7daysAgo");
      $dateRange->setEndDate("today");

      // Create the Metrics object.
      $sessions = new Google_Service_AnalyticsReporting_Metric();
      $sessions->setExpression("ga:sessions");
      $sessions->setAlias("sessions");

      // Create the ReportRequest object.
      $request = new Google_Service_AnalyticsReporting_ReportRequest();
      $request->setViewId($VIEW_ID);
      $request->setDateRanges($dateRange);
      $request->setMetrics(array($sessions));

      $body = new Google_Service_AnalyticsReporting_GetReportsRequest();
      $body->setReportRequests( array( $request) );
      return $analytics->reports->batchGet( $body );
Run Code Online (Sandbox Code Playgroud)

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

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