Windows Phone 8 Facebook Authentication - c#

I am working on an application for Windows Phone 8 and I'd like to give the possibility to the users to login with their Facebook account, so they won't have to create an account on my application.
I saw the Facebook SDK for .NET and decided to use it because it seems to be really efficient and popular.
As a beginner, I followed the tutorial in the doc of the SDK : http://facebooksdk.net/docs/phone/tutorial/
I did the exact same thing that in the tutorial, everything is okay since I login. I click on the login button, I'm redirected to what they call the "FacebookLoginPage" in the tutorial (a .xaml with an empty grid so the webbrowser can fit in it), then appears the webbrowser with the Facebook page where I can type my login and password. After that, I'm redirected to the page that asks for permissions on my Facebook account, I click on OK. Everything is good so far.
And then comes my problem. I should be redirected to what they call the "LandingPage" in the tutorial, but instead of that I'm redirected to the facebook "login_success" (https://www.facebook.com/connect/login_success.html‎) which displays "Success" and also a security warning, and then nothing happens anymore...
I thought something in my code was not right so I spend a couple of hours working on it, didn't find anything. So I tried to run the sample application that they provide in the doc of the website, I just modified the Facebook AppID in it (I've put mine), and same thing happened.
I also tried other things that I found on the Nokia Developer Wiki, same thing.
So I think something is wrong with my Facebook Application, but I can't find what it is...
Is anybody could give me some help ? I'm dying here :(
I apologize in advance for my english mistakes, and I wish you a good day !
UPDATE : I finally did it following this tutorial http://developer.nokia.com/Community/Wiki/Integrate_Facebook_to_Your_Windows_Phone_Application

The redirect to "https://www.facebook.com/connect/login_success.html‎" should contain the accessToken as a url parameter, so if you allow navigating to this url it is indeed a security risk as it exposes the AccessToken. You need to listen for the 'Navigating' event from the WebBrowser control and if the browser is navigating to "https://www.facebook.com/connect/login_success.html‎" then you need to cancel the navigation and get the AccessToken from the url parameter.
UPDATE:
It looks like FB changed their OAuth login response from ...login_success.html#access_token= to ...login_success.html?#access_token= There is now a "?" character before the "#" character.

I've seen this in a lot of apps in the store recently so it's probably not you doing something wrong but rather a change by Facebook which hasn't yet been reflected in the SDK.
Have you tried using Windows Azure Mobile Services Authentication instead?
See guides at http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-facebook-authentication/ and http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-facebook-authentication/ for more information.

I'm using the LoginButton control of the Facebook SDK .NET for WindowsPhone and have the same issue.
I Fix it, downloading the project from github Facebook-WinClient-Sdk and changing the line 186 of FacebookSessionClient class, for this one:
Uri endUri = new Uri("https://m.facebook.com/connect/login_success.html?#access_token");
The team of facebook sdk for .net will be fix this issue for sure, but i have a demo today and need it works!

Related

How to access XML file on employee sharepoint portal?

Body
Hi guys. I'll be rather brief if I can so here goes.
I made this app in C# that goes onto my employee portal and automatically gets my shifts for me every 30 minutes my using a web browser control and then it reads the HTML data from that and generates a calendar for me and also provides automated alerts.
Issue
Problem is that this web browser uses IE (yeesh help me) and it doesn't work with all parts of the site. I have done some digging around on the site and I found where the ASP site gets the data from: An XML sheet somewhere on the server. I can access this XML sheet, but only if I'm logged in (please see the attached images for more information).
Current solution
So my question is this: How do I actually login to this area?
I could login using the webbrowser and then download the XML using that, but it's too slow and too old, so is there a way I can pass my credentials through?
The URL is like this "https://www.mycoles.com.au/api/rosters/nextweek" -- I don't see any thing like ?name=myname ?pass=mypassword... soo yea. (I'm a bit new).
Further details:
Application language: C#.
Current technology: Windows forms applications/ IE web browser control.
Site backend: Microsoft Sharepoint.
Anything I'm missing? Please ask..?
Attached content
Mycoles XML Logged in
Mycoles XML Access Denied
Update:
So after a while of searching and examining the site, I tried to access the data with a c# webbrowser and it didn't work. It said that it can't download the data, however chrome is able to. Odd. I'm not sure it is an XML file anymore, rather a request and I don't have enough knowledge to work with this, so pointers anyone? Check this site out https://www.mycoles.com.au/api/rosters/nextweek and tell me what you think it is please. Thanks in advance... :)
SharePoint supports different forms of authentication. Out of the box, Active Directory-based single sign-on is provided, and forms-based (username, password) authentication can be configured.
Typically, organizations use AD SSO for its simplicity. If, once you open your desktop browser and navigate to a SharePoint site, you don't have to enter any credentials and are just logged in, then it's most likely this case. This can be either Kerberos or NTLM. The HttpWebRequest class supports both these methods.

facebook v2.2 login C#

I would like to code for a FacebookLoginDialog.cs programmed in Microsoft Visual Studio 2010 Ultimate in C#. As you may know, Facebook has upgraded its API to v2.2 and most of the information I find online is v2.0 which I am not sure if it is the same.
I tried looking at Facebook v2.0 Login with C# facebook sdk but I could not access the link provided in it and it's v2.0.
And everytime I run my code, I will face this problem when I get to facebook login.
The code is given by my friend but she did it one or two years back before the facebook api upgraded recently. There is no URL (or uri) in my friend's coding. but it works for her previously when she started coding.
I have no access to the app ID site that was created. I have created a new app ID but to no avail.
Please help! I am really in need of help.
Please check the site Url you have mentioned at the Facebook developer section.
I think problem may arise only for two reason
1> Incorrect Url at facebook developer site
2> navigateUrl parameter should be same when you send code for access token.
I've found how to solve this problem. The problem doesn't lies on the coding but the facebook developer site.
https://www.facebook.com/help/community/question/?id=542958419109491
Just enable the "Embedded browser OAuth Login" button and it will work.

How to post URL on friend's Facebook wall?

I am creating Windows 8 app with C#/XAML. I want to share URL to logged in user's friend. Facebook has removed ability to post to friends walls via Graph API after 6th Feb, 2013. Facebook recommends to use feed dialog, but that dialog can be used with the JavaScript, iOS, and Android SDKs ONLY.
So how can I achieve this in WinRT ?
UPDATE 1
I found there's one more thing available that's URL Redirection. So I need to use WebView (which is one of worst control in WinRT) temporarily to open that URL and user will press "share". This way kills the UI/UX :(
UPDATE 2
I tried to use the URL Redirection, but I am getting error stating "An error occurred. Please try later". I searched about that, I tried all the ways like sandbox mode, double checking app ID but nothing worked for me. When I use app ID of graph api explorer it works.
Working
https://www.facebook.com/dialog/feed?app_id=145634995501895&display=popup&link=http://stackoverflow.com&name=Stack Overflow&picture=http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon#2.png&redirect_uri=https://developers.facebook.com/tools/explorer&description=Stack Overflow is a question and answer site for professional and enthusiast programmers.&to=100000692924752
Not working
https://www.facebook.com/dialog/feed?app_id=159248604260839&display=popup&link=http://stackoverflow.com&name=Stack Overflow&picture=http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon#2.png&redirect_uri=https://developers.facebook.com/tools/explorer&description=Stack Overflow is a question and answer site for professional and enthusiast programmers.&to=100000692924752

Could not parse facebook oauth url

I'm fairly new to Facebook C# SDK, I followed exact same steps mentioned in the tutorial, but it didn't work, always showed "Could not parse facebook oauth url". That's the windows 8 sdk.
I then tried Windowns phone 8 sdk, every time I entered my username and password, a page with black "success" and red "SECURITY WARNING: Please treat the URL above as you would your password and do not share it with anyone." Here I downloaded the same sample source code and tried, same result.
I even downloaded the sample and ran it, same issue presented.
Does anybody run into this situation? Is it just me or something changed behind the scene?
Specs: windows 8 professional 64-bit, visual studio 2012 ultimate.
Thank you in advance.
Cheers,
Chao
I am really sorry to say I made a stupid mistake here, my Facebook app was in sandbox mode, so the url was only visible to developers and admins, since SDK is accessing the url as a visitor, stupid as me used my other account to access the app, 100% that I would be rejected.
So after I registered myself as a developer, this issue was resolved.

How to authorize my app with Facebook

I know I have seen apps that log me in using Facebook but never present me with an authorization screen. I can not, for the life of me, figure out how to do this with Windows Phone 7. The best I have been able to get is using the Facebook for C# SDK to get the authorization screen in a WebView. This looks hideous and the page does not even appear to be mobile ready.
I have searched high and low for an answer and have found nothing. Wondering if anyone can point me in the right direction to getting this to work?
Yes, I also saw this kind of apps (e.g. Spotify prompts you to enter your Facebook account credentials rather than using the normal authorization flow). My best guess is that they either some kind of premium partners and have access to some private APIs or they use custom authorization flows (e.g. when you authorize an app on a website, the system saves authorization key in the database. The same app id/secret is then used in Windows Phone app and all you need to do is to type in your email/username in order for the system to locate authorization key that was saved earlier).
I also don't like the approach of displaying Facebook login/auth using WebBrowser control (mostly because of UI inconsistency) but I'd say that this is still the way to go in most cases (because this is the official and recommended way of authorizing the app and all other approaches seem hacky for me and also have their disadvantages).
You will want to be using the "server-side authentication" approach. The following document describes how it works: Server-side authentication (read also OAuth Dialog documentation for how to configure the authentication dialog). You can change the way the UI looks by passing a display parameter (either to touch or wap).
Please note that display=touch is currently broken in Windows Phone - Facebook always falls back to wap which is deprecated and will be removed as per July 2012 update (corresponding case: Facebook API can't be used with Windows Phone apps). It's also among known issues on Facebook C# SDK project page: Facebook C# SDK - Known issues.
Hope this clarifies things a bit.

Categories

Resources