Google加上APIreturns发布时错误码401
Google plus API returns error code 401 when publishing
我正在使用 Google Plus API for .Net 在 google 上实现共享并使用 WebAuthenticationBroker。它 returns 用户登录后的一个令牌,但是当我发送片刻 post 请求它时 returns 错误 401。
我点击图片的代码是
String GoogleURL = "https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=http://www.google.com&response_type=code&scope=" + Uri.EscapeDataString("https://www.googleapis.com/auth/plus.stream.write https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.login");
PlusService service = new PlusService();
System.Uri StartUri = new Uri(GoogleURL);
System.Uri EndUri = new Uri("https://accounts.google.com/o/oauth2/approval?");
WebAuthenticationBroker.AuthenticateAndContinue(new Uri(GoogleURL), EndUri);
现在,当它 returns 验证后,我在 google 上调用了上传方法,如下所示 --
PlusService service = new PlusService();
Moment body = new Moment();
ItemScope itemScope = new ItemScope();
itemScope.Id = "replacewithuniqueforaddtarget";
itemScope.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png";
itemScope.Type = "";
itemScope.Description = "The description for the action";
itemScope.Name = "An example of add activity";
body.Object = itemScope;
body.Type = "http://schema.org/AddAction";
MomentsResource.InsertRequest insert =
new MomentsResource.InsertRequest(
service,
body,
"me",
MomentsResource.InsertRequest.CollectionEnum.Vault);
Moment wrote = insert.Execute();
但它 returns 异常 401。我在 Google Console Help 上找到 post 的代码。有人可以帮忙吗?
我终于发现 google API 不直接对第三方开发人员开放,这使我的案例无效,不得不为此使用 HTTP 方法。感谢@DalmTo 的回答。
我正在使用 Google Plus API for .Net 在 google 上实现共享并使用 WebAuthenticationBroker。它 returns 用户登录后的一个令牌,但是当我发送片刻 post 请求它时 returns 错误 401。
我点击图片的代码是
String GoogleURL = "https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=http://www.google.com&response_type=code&scope=" + Uri.EscapeDataString("https://www.googleapis.com/auth/plus.stream.write https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.login");
PlusService service = new PlusService();
System.Uri StartUri = new Uri(GoogleURL);
System.Uri EndUri = new Uri("https://accounts.google.com/o/oauth2/approval?");
WebAuthenticationBroker.AuthenticateAndContinue(new Uri(GoogleURL), EndUri);
现在,当它 returns 验证后,我在 google 上调用了上传方法,如下所示 --
PlusService service = new PlusService();
Moment body = new Moment();
ItemScope itemScope = new ItemScope();
itemScope.Id = "replacewithuniqueforaddtarget";
itemScope.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png";
itemScope.Type = "";
itemScope.Description = "The description for the action";
itemScope.Name = "An example of add activity";
body.Object = itemScope;
body.Type = "http://schema.org/AddAction";
MomentsResource.InsertRequest insert =
new MomentsResource.InsertRequest(
service,
body,
"me",
MomentsResource.InsertRequest.CollectionEnum.Vault);
Moment wrote = insert.Execute();
但它 returns 异常 401。我在 Google Console Help 上找到 post 的代码。有人可以帮忙吗?
我终于发现 google API 不直接对第三方开发人员开放,这使我的案例无效,不得不为此使用 HTTP 方法。感谢@DalmTo 的回答。