Google app engine Google Plus域名SAPI广域自动化
早上好,我正在尝试将Google app engine Google Plus域名SAPI广域自动化,google-app-engine,google-plus,Google App Engine,Google Plus,早上好,我正在尝试将Google+域API与我的公司域集成,但我遇到了一些问题 我正在尝试java快速入门之后的java方法,但在实现代码后,google服务器的响应是: Authenticate the domain for hugo.catarino@outsystems.com Inserting activity 10/Set/2013 17:08:49 com.google.api.client.googleapis.services.AbstractGoogleClient <
Google+域
API与我的公司域集成,但我遇到了一些问题
我正在尝试java快速入门之后的java方法,但在实现代码后,google服务器的响应是:
Authenticate the domain for hugo.catarino@outsystems.com
Inserting activity
10/Set/2013 17:08:49 com.google.api.client.googleapis.services.AbstractGoogleClient <init>
WARNING: Application name is not set. Call Builder#setApplicationName.
Exception in thread "main" com.google.api.client.auth.oauth2.TokenResponseException:400 Bad Request
{
"error" : "access_denied"
}
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:269)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)
at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:858)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.google.plus.samples.quickstart.domains.DomainDelegation.main(DomainDelegation.java:160)
我的主类的代码如下所示:
Plus service = authenticate();
String userId = "me";
String msg = "Happy Monday! #caseofthemondays";
System.out.println("Inserting activity");
// Create the audience of the post
PlusAclentryResource res = new PlusAclentryResource();
// Share to the domain
res.setType("domain");
List<PlusAclentryResource> aclEntries = new ArrayList<PlusAclentryResource>();
aclEntries.add(res);
Acl acl = new Acl();
acl.setItems(aclEntries);
// Required, this does the domain restriction
acl.setDomainRestricted(true);
Activity activity = new Activity()
.setObject(new Activity.PlusObject().setOriginalContent(msg))
.setAccess(acl);
activity = service.activities().insert(userId, activity).execute();
System.out.println(activity);
我的范围定义是:
private static final List<String> SCOPE = Arrays.asList(
"https://www.googleapis.com/auth/plus.circles.read",
"https://www.googleapis.com/auth/plus.circles.write",
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/plus.media.upload",
"https://www.googleapis.com/auth/plus.stream.read",
"https://www.googleapis.com/auth/plus.stream.write");
private static final List SCOPE=Arrays.asList(
"https://www.googleapis.com/auth/plus.circles.read",
"https://www.googleapis.com/auth/plus.circles.write",
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/plus.media.upload",
"https://www.googleapis.com/auth/plus.stream.read",
"https://www.googleapis.com/auth/plus.stream.write");
我在这里有点不知所措,有没有办法调试这个问题,或者知道为什么拒绝访问?有几件事你应该检查一下 首先,您从下载的私钥文件是否与代码一起位于正确的路径中?此文件由以下变量引用。这需要告诉OAuth客户端库在哪里找到文件
private static final String SERVICE_ACCOUNT_PKCS12_FILE_PATH =
"/path/to/<public_key_fingerprint>-privatekey.p12";
通常,最好只请求所需的作用域,而不是所有可用的作用域
第三,确保您生成的客户端ID是管理控制台条目上列出的,用于指定允许的作用域。代码中的作用域需要与控制台中的作用域匹配。根据需要,它不能是每个代码段中作用域的子集。它必须是完全匹配的。好的,我会向cpanel的负责人询问excat匹配和作用域的顺序以匹配,我会在这里给出反馈,谢谢,这是cpanel上的定义:googleapis.com/auth/plus.circles.read这是我的作用域定义:private static final List Scope=Arrays.asList(“,”“, "", "", "", ");我用附加检查编辑了我的答案。您是否将私钥文件与SERVICE_ACCOUNT_PKCS12_file_PATH变量放在正确的位置?我的请求是quck start的示例代码。我只更改电子邮件、用户和密钥。您可以发布发出授权请求的代码吗?它与示例完全相同,以便更具体地说明c、 你能包括你设置的新变量吗?@user2753937我面临同样的问题,你解决过这个问题吗?
private static final List<String> SCOPE = Arrays.asList(
"https://www.googleapis.com/auth/plus.circles.read",
"https://www.googleapis.com/auth/plus.circles.write",
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/plus.media.upload",
"https://www.googleapis.com/auth/plus.stream.read",
"https://www.googleapis.com/auth/plus.stream.write");
private static final String SERVICE_ACCOUNT_PKCS12_FILE_PATH =
"/path/to/<public_key_fingerprint>-privatekey.p12";
private static final List<String> SCOPE = Arrays.asList(
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/plus.circles.read",
"https://www.googleapis.com/auth/plus.circles.write",
"https://www.googleapis.com/auth/plus.media.upload",
"https://www.googleapis.com/auth/plus.stream.read",
"https://www.googleapis.com/auth/plus.stream.write");