[英]Google Access on WP7
I am having problems building an app that can access google accounts. 我在构建可以访问Google帐户的应用程序时遇到问题。 I have the following code that gets the sign in 我有以下代码可以登录 page for google accounts and then the access permissions page is also displayed! google帐户页面,然后还会显示访问权限页面! . 。 Once i click on "Allow Access" the app is redirected to error page 一旦我单击“允许访问”,该应用程序将重定向到错误页面 . 。 here are few screenshots so that whoever is trying to help can understand better.. and below is the code that am using 这是一些屏幕截图,以便任何试图提供帮助的人都可以更好地了解..下面是正在使用的代码
private void browseGoogle_Loaded(object sender, RoutedEventArgs e)
{
string address = "https://accounts.google.com/o/oauth2/auth" +
"?client_id=" + "*******.apps.googleusercontent.com" +
"&scope=" + "https://www.googleapis.com/auth/plus.me" +
"&response_type=code" +
"&redirect_uri=" + "https://www.****.com/oauth2callback";
browseGoogle.Navigate(new Uri(address, UriKind.Absolute));
}
https://accounts.google.com/o/oauth2/approval?as=634f855389bf10ff&hl=en_GB&xsrfsign=APsBz4gAAAAAUHZvwB3xTqisyv8hEcWem5X3eKvwAHN9 this is the URI its navigating to after allow access is selected/clicked. https://accounts.google.com/o/oauth2/approval?as=634f855389bf10ff&hl=zh_HK&xsrfsign=APsBz4gAAAAAUHZvwB3xTqisyv8hEcWem5X3eKvwAHN9这是在选择/单击允许访问后导航至的URI。 What does this mean? 这是什么意思?
This is all am doing. 这都在做。 My BrowserNavigated Method doesn't contain any code as of now. 到目前为止,我的BrowserNavigated方法不包含任何代码。 I dunno what to do further.hence seeking help. 我不知道该怎么做。因此寻求帮助。 Please help me resolve this issue.. All answers and suggestion appreciated. 请帮助我解决此问题。感谢所有答案和建议。
Just check the GDrive open-source application code here . 只需在此处查看GDrive开源应用程序代码。
The Authorization View and ViewModel show you how you can make OAuth sign-in with Google credentials. Authorization View和ViewModel向您展示如何使用Google凭据进行OAuth登录。
Download the code, read the pre-build instructions on the site, and test it! 下载代码,阅读网站上的预构建说明,然后进行测试!
private void browseGoogle_Loaded(object sender, RoutedEventArgs e)
{
try
{
StringBuilder autheticateURL = new StringBuilder();
autheticateURL.Append(GmailSettings.AuthorizeUri).Append("?client_id=").Append(GmailSettings.clientID).Append("&scope=").
Append(GmailSettings.ScopeValue).Append("&response_type=code").Append("&redirect_uri=").Append(GmailSettings.CallbackUri);
browseGoogle.Navigate(new Uri(autheticateURL.ToString(), UriKind.Absolute));
}
catch (Exception ex)
{
Logger.log(TAG, "browseGoogle_Loaded()", ex.Message);
}
}
/// <summary>
/// Called when the web browser initiates Navigation to various pages
/// </summary>
/// <param name="sender">Browser</param>
/// <param name="e">Navigating event arguments</param>
private void browseGoogle_Navigating(object sender, NavigatingEventArgs e)
{
try
{
string hostName = e.Uri.Host;
string URL = e.Uri.ToString();
if (hostName.StartsWith("localhost"))
{
NavigationService.Navigate(new Uri("/HomePage.xaml", UriKind.Relative));
}
}
catch (Exception ex)
{
Logger.log(TAG, "browseGoogle_Navigating()", ex.Message);
}
}
The XAML goes like this XAML像这样
<phone:WebBrowser x:Name="browseGoogle" Loaded="browseGoogle_Loaded" IsScriptEnabled="true" Navigating="browseGoogle_Navigating" />
My mistakes were two:- 1) as vignesh has mentioned in his comments I was using a wrong Redirect URI. 我的错误有两个:-1)正如vignesh在他的评论中提到的,我使用了错误的重定向URI。 2)IsScriptEnabled was not at all set in my Web Browser Controls. 2)根本没有在我的Web浏览器控件中设置IsScriptEnabled。 Once i set it true everything was fine. 一旦设置为true,一切都很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.