FacebookSessionClient Given URL is not allowed by the Application configuration - c#

I'm developing a Windows 8.1 Store Apps with .NET Framework 4.5.1, C#, Facebook 6.8.0 SDK and Facebook.Client 0.9.1-alpha.
Probably I'm not doing it well, but I want to add Facebook Login to my app, and to do it, I'm following this tutorial: Facebook Scrumptious tutorial for Windows 8 (I think it is out of date).
This is my code:
private async Task DoFacebookLogin()
{
session = await App.FacebookSessionClient.LoginAsync("user_about_me,read_stream");
Debug.WriteLine(session.AccessToken);
Debug.WriteLine(session.FacebookId);
}
I'm using FacebookSessionClient to do a login, but I get this message:
The application configuration does not allow the URL provided .: One or more
of the URLs you provided are not permitted by the application configuration.
Must match the URL of the website or the URL of the main page of the application,
or domain to be a subdomain of one of the application domains.
Can I use FacebookSessionClient on a Windows 8.1 Store app? I think it is only for web applications.
Meanwhile I'm going to test this tutorial. Here they use WebAuthenticationBroker.

so I had the same code sample work just fine until recently. I believe that you have to go into Facebook and enter your ID for your app. once that information is available, then FB will know your app and stop throwing those exceptions. I'm in process of verifying right now.

Related

How to sign into UWP app with microsoft account?

I am designing a uwp c# app that contains in app purchases. This app will be installed on public systems, so I want the app to pop up with a sign in screen when it starts. I want users to sign in with their microsoft accounts, so that they can make purchases on their account.
I am following the instructions for this at https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-windows-store-dotnet-get-started-users . To sign in with Microsoft, you need to "configure your preferred identity provider" and for microsoft, the instructions are here https://learn.microsoft.com/en-us/azure/app-service/configure-authentication-provider-microsoft .
The second website tells you to add a domain name for your app, But I dont know what that Is.
In Redirect URIs, select Web, and then type https://<app-domain-name>/.auth/login/microsoftaccount/callback supply the endpoint for your application. Replace <app-domain-name> with the domain name of your app. For example, https://contoso.azurewebsites.net/.auth/login/microsoftaccount/callback.
What would be my redirect URI for my app? also, are there any code samples of this so that I can see how it works better?
I've just published updated HOWTO documents for authentication, specifically targetting Microsoft accounts. Take a look at the Quickstart guides for your platform at https://azure.github.io/azure-mobile-apps for details.
short version - MSA no longer uses Microsoft Account (which is deprecated) - it's done through Azure Active Directory now.

Adding Authentication to UWP apps with Azure Mobile App as backend

I am working on UWP app which requires users to login using social identity providers like Microsoft, Google etc.
I have followed the quickstart guide here which describes how the authentication can be added.
In the UWP Quickstart app the installed version of Microsoft.Azure.Mobile.Client is 3.1.0, if I upgrade this to the latest version i.e. 4.0.0, an error is thrown on the line LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount) that LoginAsync has no overloaded methods that take 1 argument. To resolve this I added a SingleSignOn parameter to the method which is a boolean
var user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount, true);
When I run the application the Microsoft login popup is shown successfully, however when the users logs in, the popup does not go away and control never returns to the app. Following is the screenshot:
If I close the popup manually then an exception is thrown :
Authentication was cancelled by the user
So is this a Microsoft.Azure.Mobile.Client Nuget package version issue or am I missing something here.
Any help would be much appreciated.
Ok, I'll answer to you question now, because I was able to solve it just a couple seconds ago.
So you are using UWP, I'm using Template 10 and I've been able to make it work on both, firstable update to v4.0.0 or v4.0.1 according to what i found out was because google authentication stopped allowing web views for authentication and the concern for Azure-Mobile-Net-Client team was that all OAuth provider would adopt that behavior in the future base on an article that you can find here if you are interested:
Modernizing OAuth interactions in Native Apps for Better Usability and Security
after this being said we are in the middle of a big change here, so in order to make it work you need to set your mobile app service to allow external redirects using url_scheme_of_your_app as shown on microsoft documentations tutorial.
So the step are the next ones:
1.- Go to Azure Portal
2.- Go to your MobileApp Service
3.- Choose Authentication/Authorization
4.- at Allowed External Redirect URLs write this: {urischeme}://easyauth.callback
(meaning that urischeme must be alphanumeric word beginning with a letter).
5.- Save changes.
Now after you have done that now you gotta work on your client
then if you are using UWP follow this tutorial:
Add Authentication to your UWP.
and that should be enough, if you are using template 10 all you gotta do is at OnStartAsync Method use this code:
if(startKind == StartKind.Activate)
{
ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs;
cloudService.ResumeWithUrl(protocolArgs.Uri);
}
you saved tons of code at the tutorial because you gotta write code at OnNavigatedTo() Method and at OnActivated() method at App.Xaml.cs
thats for the architecture in UWP and at Template 10 that acts like a wrapper of Application class and simplifies its usage.
Hopefully this helps you, also you will notice that when you first sign in at your app using urischeme it opens your default browser and stays open after successfully logged in.
Also singlesignon overload method doesnt work at all yet, they are still working on those issues.
hopefully my answer helps you!!!
I just wanted to add my solution for xamarin.forms on uwp, which should be actually same as we are doing redirecting and login on native level. I followed this article https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-users
but there was something confusing about url scheme of your app part when you define the return url.
Basically you define return url in 4 places and they sound like the same but they are different
1) you define on facebook developer page. it should (use https) https://myapi.azurewebsites.net//easyauth.callback
2) on the azure portal for allowed external redirect urls
add here 2: https://myapi.azurewebsites.net//easyauth.callback, myapp//easyauth.callback
3) uwp package manifest- declaration. add myapp as name
4) Login call to azure mobile services: Client.LoginAsync(provider, "myapp");
So basically myapp (this is name you choose) should be available in azure portal and same name used in your uwp project. otherwise even login is successful, you end up with this screen instead of redirected back to the app.

Facebook login via application or webview if app is not installed in Windows phone 8

Basically I want to achieve the same fucntionality which you normally see in android or ios devices. So if I click on login it should open facebook application(not webview) if facebook is installed but in case app is not installed it should open webview.
Currently it shows me a message do you want to search on store which I don't want.
Any help will be highly appreciated.
Thanks
Vinod
Windows Phone SDK only has the API to launch an app from another app which wouldn't work in your case since you would not be able to share session tokens.
Your best approach to achieving this would be to try out the third party Facebook SDK for .NET. Take a look at the Login API which seems to provide the ability to invoke the facebook application on the app and if not available would take the user to the store (LoginBehaviorApplicationOnly - Windows Phone 8.1).
I understand you would like to bring up the WebView if app isn't available but this SDK doesn't seem to have that functionality. You could contribute to the project or request a feature addition.
Hope this gives you a good start?

azure acs authentication in winrt

I'm trying to authenticate users in a winrt metro app using Azure ACS.
I've set up a relying party in azure with a simple webtoken.
on windows 8 I've installed the azure toolkit. When I created a new project from the winrt cloud (notifications + acs) template and I fill in all necessary parameters I can run the app, I get the live ID login screen but when I enter my credentials I get a message saying "We can't load that page".
Can anyone help me with this?
With "I fill in all necessary parameters" I'm assuming you mean the Configuration.xml file contains the necessary information to your ACS namespace etc...
Now, filling in this information and configuring ACS isn't enough to make the sample work. If you take a closer look at the Configuration.xml file, you'll see the following elements:
<!--Relying party return Url. The bouncer service url that will parse the token from ACS.-->
<ReturnUrl>https://127.0.0.1/bouncer</ReturnUrl>
<!--Authentication End Url. The bouncer service url used to validate if the authentication process is done.-->
<EndUrl>https://127.0.0.1/bouncer/end</EndUrl>
These are URLs from an Azure application you'll also need to run in order for the sample to work. In the toolkit you'll find the following directory:
WATWindows.Setup.v1.2.4\Samples\Notifications.CSharp\Notifications.Backend
To be able to run the sample application you'll need to start this backend application first.
And did you already run the SetupSample.cmd script in the WATWindows.Setup.v1.2.4\Samples\Notifications.CSharp directory?

Uploading a c# application to a facebook application

I have created a Windows application using C# and would like to know how to upload it to Facebook application.
I have set up the Facebook application, all I need to do is add the application. I can't seem to find out how.
Facebook applications are not true applications in the sense of the word. You do not download or install Facebook apps... they are more like web applications that you log in to with your Facebook account. When you "add" a Facebook application to your Facebook account, all you are really doing is setting some permission flags to give that application access to your Facebook data. Once you've "added" it, each time you load a page from the app, Facebook sends it your Facebook id, which lets the app interact with you and work with your social data. There's no concept of downloading involved.
If your C# app is a desktop application, then you can still integrate it with Facebook, but you're going to need to do a bit more work. You'll need Facebook Connect in order to establish the proper communication. You might want to start with Authorizing and Authentication for Desktop Applications, and do a bit of poking around in that wiki to find out more.

Categories