问题
I wrote an Android application that uses Azure to perform user login with Google, Twitter and Facebook; it uses Microsoft.WindowsAzure.MobileServices.Android.dll and with this I'm able to do something like
await Client.LoginAsync(context, MobileServiceAuthenticationProvider.Google);
(in Azure I set ids and secrets to use Google, Facebook and Twitter).
Now I'm developing a Windows app (desktop app) using Windows 7, VS2012 and Framework 4.5 and I'd like to perform same login (so I can get authentication token and use it to query my sql database); I used NuGet to import Microsoft.WindowsAzure.Mobile package and I see referenced both Microsoft.WindowsAzure.Mobile and Microsoft.WindowsAzure.Mobile.Ext.
When I try to use LoginAsync, similar syntax I used in Android is missing.
According to this link http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/work-with-net-client-library/#caching in extension package there should be an extension method that lets me use
user = await client.LoginAsync(MobileServiceAuthenticationProvider.Google);
but VS cannot see it and so I cannot use it.
I just see method
LoginAsync(MobileServiceAuthenticationProvider provider, JsonObject token)
but I don't need it honestly...
Am I missing something?
回答1:
The "simplified", or "browser-based" login method is available on all supported platforms, except the full .NET Framework 4.5. That platform lacks that functionality because there are cases where it cannot display a web interface where the user can enter their credentials. For example, it can be used in a backend service (see an example at this post). It can also be a console application, in which there’s no “native” way to display a web page. Even on project types with "native" UI components, such as WinForms or WPF, there's no "natural" way to show a login page - if the window were WPF-based, it wouldn't look natural in a WinForms app, and vice-versa.
For a specific platform, however, you can add that method as an extension method. The post at http://blogs.msdn.com/b/carlosfigueira/archive/2013/08/27/web-based-login-on-wpf-projects-for-azure-mobile-services.aspx talks exactly about that, and it has some code showing how this can be done.
来源:https://stackoverflow.com/questions/18411397/loginasync-missing