您必须通过身份验证才能发出请求 - GoogleAuthenticator

时间:2013-06-28 21:03:28

标签: xamarin.android xamarin google-api-dotnet-client

我正在尝试使用Xamarin在Android手机上使用.NET API上传视频。我无法进行身份验证,并在主题行中收到错误。以下是Xamarin的代码:

https://github.com/xamarin/google-apis/blob/master/src/Android/Google.Apis.Android/Apis/Authentication/GoogleAuthenticator.cs

我使用了HttpScoop,似乎没有网络流量。

我正在使用网络应用程序ID:

网络应用程序的客户端ID

客户ID:

* .apps.googleusercontent.com

电子邮件地址:

* @ developer.gserviceaccount.com

客户密码:

- *

重定向URI:http://jmawebtechnologies.com

JavaScript起源:http://jmawebtechnologies.com

以下是我创建Google身份验证器的方法:

GoogleAuthenticator Auth ()
{
return new Google.Apis.Authentication.OAuth2.GoogleAuthenticator (ClientID, new Uri ("http://jmawebtechnologies.com"),                                                                      Google.Apis.Youtube.v3.YoutubeService.Scopes.YoutubeUpload.ToString());
}

1 个答案:

答案 0 :(得分:0)

我发现我必须调用GetUI。这将打开一个用户登录Google的浏览器窗口。

StartActivity(auth2.GetUI (this));

                    auth2.Completed += (sender, eventArgs) => {


                        if (eventArgs.IsAuthenticated) {
                            MakeAlert("Is auth", "Accepted!");
                        } else {
                            // The user cancelled
                            MakeAlert("Is not auth", "failure");
                        }
                    };