我正在尝试使用dotnet-client在Google+中编写活动。问题是,我似乎无法正确地获得我的客户端应用程序的配置。根据Google+ Sign-In configuration和this SO question,我们需要添加requestvisibleactions参数。我做到了,但没有奏效。我正在使用范围https://www.googleapis.com/auth/plus.login
,我甚至添加了范围https://www.googleapis.com/auth/plus.moments.write
,但插入仍然无效。Google+插入时刻使用google-api-dotnet-client
这是我的请求的URL是什么样子:
https://accounts.google.com/ServiceLogin?service=lso&passive=1209600&continue=https://accounts.google.com/o/oauth2/auth?scope%3Dhttps://www.googleapis.com/auth/plus.login%2Bhttps://www.googleapis.com/auth/plus.moments.write%26response_type%3Dcode%26redirect_uri%3Dhttp://localhost/%26state%3D%26requestvisibleactions%3Dhttp://schemas.google.com/AddActivity%26client_id%3D000.apps.googleusercontent.com%26request_visible_actions%3Dhttp://schemas.google.com/AddActivity%26hl%3Den%26from_login%3D1%26as%3D-1fbe06f1c6120f4d<mpl=popup&shdf=Cm4LEhF0aGlyZFBhcnR5TG9nb1VybBoADAsSFXRoaXJkUGFydHlEaXNwbGF5TmFtZRoHQ2hpa3V0bwwLEgZkb21haW4aB0NoaWt1dG8MCxIVdGhpcmRQYXJ0eURpc3BsYXlUeXBlGgdERUZBVUxUDBIDbHNvIhTeWybcoJ9pXSeN2t-k8A4SUbfhsygBMhQivAmfNSs_LkjXXZ7bPxilXgjMsQ&scc=1
你可以从这里看到,有一个request_visible_actions
,我甚至增加了一个有没有底线的情况下,我得到的参数错误( requestvisibleactions
)。
让我说,我的应用程序正在通过API成功验证。我可以在通过身份验证后获取用户的个人资料,并且它位于我的应用失败的“插入时刻”部分。我的插入代码:
var body = new Moment();
var target = new ItemScope();
target.Id = referenceId;
target.Image = image;
target.Type = "http://schemas.google.com/AddActivity";
target.Description = description;
target.Name = caption;
body.Target = target;
body.Type = "http://schemas.google.com/AddActivity";
var insert =
new MomentsResource.InsertRequest(
// this is a valid service instance as I am using this to query the user's profile
_plusService,
body,
id,
MomentsResource.Collection.Vault);
Moment result = null;
try
{
result = insert.Fetch();
}
catch (ThreadAbortException)
{
// User was not yet authenticated and is being forwarded to the authorization page.
throw;
}
catch (Google.GoogleApiRequestException requestEx)
{
// here I get a 401 Unauthorized error
}
catch (Exception ex)
{
} `
您是否使用了页面上的Google+登录按钮?如果是这样,你可以将该标记粘贴到你的文章中?或者您是否使用原生OAuth来触发您显示的网址?我相信,从URL的形成方式来看,您并未使用该按钮来触发身份验证,是否有原因? – BrettJ 2013-03-07 15:25:45
我正在使用dotnet客户端。我展示的URL是由API构建的。我知道dotnet客户端使用DotNetOpenAuth(DNOA),所以我认为这是建立URL的DNOA。身份验证通过'Google.Apis.Authentication.OAuth2.OAuth2Authenticator'完成。 – 2013-03-08 04:22:44
哦,对不起,我错过了回答你的一个问题。我使用我自己的链接/按钮,在那里我调用一个启动身份验证的方法。我的验证码基于样本。如果需要,我也可以发布它。 – 2013-03-08 04:39:59