Tag: google api

Java SSLException:证书中的主机名与www.googleapis.com不匹配

环境 :Mac OS X Lion和Linux Debian squeeze / sid,JDK 1.7.0和JDK 1.6.0_27 错误 : javax.net.ssl.SSLException: hostname in certificate didn’t match: != OR OR . 我在所有上述OS / JDK组合中都收到此错误。 背景 :我正在使用google-api-services-customsearch和google-api-service-shopping jar来向Google发送网络服务电话。 我的电话一直工作到一天前。 从昨天开始,代码开始抛出…… javax.net.ssl.SSLException: hostname in certificate didn’t match: != OR OR at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:228) at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54) ….. at com.google.api.services.shopping.Shopping$Products$List.execute(Shopping.java:156) 我尝试使用此处的说明将证书导入cacerts密钥库,但这似乎无法解决问题。

Google ClientLogin身份validation

我尝试使用ClientLogin进行身份validation URL url = new URL(“https://www.google.com/accounts/ClientLogin”); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod(“POST”); connection.setRequestProperty(“Email”, “testonly%2Ein%2E2011%40gmail%2Ecom”); connection.setRequestProperty(“Passwd”, “mypass”); connection.setRequestProperty(“accountType”, “HOSTED”); connection.setRequestProperty(“service”, “apps”); connection.connect(); 但我得到Error=BadAuthentication 。 我该如何纠正我的代码?

如何使用Java访问Google Calendar REST API v3

我正在开发一个项目,我必须使用REST访问一组Google日历并使用Java。 该程序位于私人非Google服务器上,定期(通过cron作业)连接到Google帐户,获取链接到该帐户的日历列表,获取每个日历的上个月的事件,并返回包含所有日历的XML文件信息。 该程序应该能够在没有任何用户输入的情况下执行和访问日历。 目前,该项目指定只读取日历,而不是修改日历(因此只会进行GET / LIST调用)。 我查看了Google文档并使用客户端库查看了示例代码,并且在访问日历API之前,几乎所有给出的示例都需要OAuth 2.0用户同意。 甚至REST API文档页面也要求您激活OAuth 2.0以返回所请求的信息(否则返回HTTP 40X错误代码和包含错误状态和消息的JSON文件)。 我如何连接到Google Calendar REST API以获取我需要的信息,一切都是通过REST调用完成的,并且在执行时无需用户同意? 或者我是否过于复杂,只需要在Google云端控制台的Resgistered Apps部分中找到“服务器密钥”? 或者我是否要求同时使用OAuth和开发人员密钥? (我发现有人在标题下提到它:Google Calendar API v3硬编码凭据;然而,问题和解决方案是针对PHP的,我不知道Java中是否可能存在类似的东西)。 我确实看到了创建一个带有服务帐户的JWT的可能性(使用Google云控制台,注册为Web应用程序,并且它位于’证书’下),但是我没有找到如何将这个与REST调用一起使用一个Java程序。 以下链接( http://aleksz-programming.blogspot.be/2012/11/google-calendar-api.html )表示可以通过“Web服务器应用程序”或“已安装的应用程序”访问信息,但不能不详细说明。 但是,在Google OAuth 2.0文档页面上,“Web服务器应用程序”部分仍需要用户输入和同意。 这是真的吗? 我还找到了此页面( https://developers.google.com/accounts/docs/OAuth2Login ),但未能看到如何在不使用用户同意页面的情况下使用它。 我确实看到了一些“双腿OAuth”的引用。 但似乎这不是OAuth 2.0,而是版本1是做事。 这是我项目的可能解决方案吗? 如果是这样,我需要从Google Cloud Console获取哪些信息才能使其正常运行? 我希望我已经提供了足够的信息来说明我正在寻找什么,而且到目前为止还没有涵盖这个问题。 我做了研究,并没有找到足够接近我所寻找的东西。 我无法发布超过2个链接(缺乏声誉),但确实查看了Google Calendar v3 REST API,以及指定创建JWT的页面。

当我尝试初始化GoogleMap对象时,我得到一个NullPointerException

我正在尝试在我的一个片段类中显示一个地图。 我在地图的XML类中创建了一个片段,并使用它如下: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_profile, container, false); GoogleMap mapFragment = ((SupportMapFragment) getFragmentManager() .findFragmentById(R.id.map)).getMap(); Marker hamburg = mapFragment.addMarker(new MarkerOptions().position(HAMBURG) .title(“Hamburg”)); Marker kiel = mapFragment.addMarker(new MarkerOptions() .position(KIEL) .title(“Kiel”) .snippet(“Kiel is cool”) .icon(BitmapDescriptorFactory .fromResource(R.drawable.icon))); 这是基于我在网上找到的教程。 问题是我不断得到一个NullPointerException,我初始化mapFragment,我不知道为什么。 有谁知道为什么会这样? 非常感谢任何帮助。 logcat的: java.lang.NullPointerException at com.example.sv_laptop03.snapchain.Profile.onCreateView(Profile.java:65) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955) at […]

TokenResponseException:尝试访问Admin SDK Google API时出现401 Unauthorized Exception。

我正在尝试通过访问Google Admin SDK API对我的域中的用户进行提取。 然而,我获得了401未经授权的例外。 下面的代码是我的设置类,其中包含调用API的方法。 package com.brookfieldres.operations; import java.io.File; import java.io.IOException; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.ResourceBundle; import org.apache.log4j.Logger; import com.brookfieldres.common.Constants; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential.Builder; import com.google.api.services.admin.directory.Directory; import com.google.api.services.admin.directory.DirectoryScopes; public class GCAuthentication { private static final Logger _Log = Logger.getLogger(GCAuthentication.class.getName()); static ResourceBundle resources = ResourceBundle.getBundle(“Resources”); // public static String serviceAcc = resources.getString(“SERVICE_ACC_EMAIL”); // public […]

问题com.google.gdata.util.ResourceNotFoundException:Google Analytic无法找到

问题描述 我正在使用Google分析来显示网站的展示次数/跳出率。 昨天之前function正常。 但现在我收到了一个错误 com.google.gdata.util.ResourceNotFoundException: Not Found Error 404 (Not Found)!!1 *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(https://www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}} 404. That’s an error. The requested URL /analytics/feeds/accounts/default was not found on this server. That’s all we know. at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:599) at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564) at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560) at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538) at […]

使用Google表格API和服务帐户时禁止使用403

我有一个使用服务帐户的应用程序(因为它从一个cron作业运行,因此我无法通过浏览器中的用户进行授权)。 以下是我创建工作表服务的方法: private static final String APPLICATION_NAME = “my app”; private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); private static HttpTransport HTTP_TRANSPORT; static { try { HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); } catch (GeneralSecurityException | IOException e) { e.printStackTrace(); } } private static final List SCOPES = Collections.singletonList(SheetsScopes.SPREADSHEETS); private static Credential authorize() throws IOException, GeneralSecurityException { GoogleCredential credential […]

谷歌+域名API快速启动java无法正常工作

我正在尝试使用Google +中提供的域API,我正在尝试使用域范围委派快速启动java我已按照步骤操作,我也请求我的域管理员授予对我创建的项目的访问权限在控制台中,恢复我可以编译java文件,但是当我运行时,我得到一个404错误,这里是代码: /* * Copyright 2013 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the “License”); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law […]

Google API v3检索所有联系人

我正在编写一个代码(用Java),让我可以使用谷歌API v3从我的谷歌帐户获取所有联系人。 我的问题是,在我成功授权访问帐户后,我只从“最常联系”组中获取联系人。 作为feedURL,我根据本教程使用https://www.google.com/m8/feeds/contacts/default/full/ 。 基本上我的代码是这个例子的复制粘贴,所以如何获得我的所有联系人?

将经度和经度传递给Android中的Google API地方搜索

几个星期以来,我一直在寻找这个。 我是一名新手java程序员,但我已经能够拼凑出一个可以在同一个类中使用硬编码的双纬度和经度的应用程序。 它将显示这些点周围的当前位置列表。 我有另一个单独的类,其方法能够基于gps / network获取当前位置,但我无法将从第二个类创建的变量传递给PlaceRequest类。 我已经查看了上述主题的所有教程,但没有任何组合当前位置和地点搜索结果。 我声明了两个getter但是无法在这些中调用变量。 再一次是一个菜鸟,所以可能很容易解决。 有任何想法吗? 更新 – 这是我的代码到目前为止:GooglePlaceActivity.java public class GooglePlaceActivity extends Activity { /** Called when the activity is first created. */ Button btn1; TextView txt1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.main); btn1 = (Button)findViewById(R.id.button1); txt1 = (TextView)findViewById(R.id.textView1); btn1.setOnClickListener(l); } private class SearchSrv extends AsyncTask{ @Override […]