I'm using the following step by step guide to connect to Facebook Connect:
http://msdn.microsoft.com/en-us/windows/ee702803.aspx
However I have a problem at the 'Authentication and Initiating a Session' stage.
When I go through the steps, I click on 'Connect' in my browser, which opens a popup, where I login to Facebook and 'Allow' the application to access my account. I'm then redirected to the filename I specify in thw 2nd parameter of the javascript function 'FB.init'.
However, this page then displays:
Please sign-in with Facebook.
Why is this happening?
I'm developing this on localhost, I don't know if that could cause a problem? Please help! Thanks.
You actually can use localhost. The one problem you may have is that there is a bug with the Facebook Javascript SDK in internet explorer if you are on a port other than 80 or 443. http://github.com/facebook/connect-js/issues#issue/106
If you check out my Facebook .Net SDK on codeplex you can download the sample app. As it is configured it will run locally. The one thing is you need to set your site url and/or canvas url to point to http://localhost:port#/
Do download the sample go to: http://facebooksdk.codeplex.com
I ran into a similar problem where I could not test Facebook on localhost. Due to security requirements from Facebook you must test from the domain you used to register your application.
Create a dev.yourname.com subdomain and test it there.
Related
I just created a webform that is hosted in my Azure subscription. I set it up with authenication via my works Azure directory for authenticating users. In debug this works fine and I am able to login with my work credentials and then view the website via local host.
I have published this to my Azure and it says it is running and working fine. So when I try to connect to the website it continuously redirects me to the localhost resulting in an error.
I have checked the web config.
Here is the google network chain of events when it occurs.
I am really lost as to what is wrong and what I need to do to fix this so any help would be greatly appreciated. I'm sorry I can't offer more but I don't even know what is wrong to begin with or where to look. Is there some setting in Azure that I need to add the website too?
I have solved this issue. Since it was such a pain I will keep this up as I couldn't find any answers on this. It was actually quite simple.
You have two options. The one I did and which worked was changing the publish profile as below:
Add the domain where the authentication is occurring. So if you have your web app hosted by a different azure account that which is authenticating the users, use the one that is authenticating.
This will create two versions of your app on the site one for local host and one for the actual site.
The second option(I have not tried this but it should work) is to go to the Azure account where you are authenticating the users and go to applications and then configure. Change the APP URL from local host to the url you are trying to get to.
Here is an excellent link that explains how to do this clearly.
Click this link for detailed explanation
I also had this issue and took these steps to resolve
navigate to the app registration in AAD
Open the manifest
Change the ReplyUrl to the url of the app (e.g. http://appname.azurewebsites.net)
Then I got the error
Bad Request - Request Too Long HTTP Error 400. The size of the request headers is too long.
Next I cleared all cookies from the browser, and this changed the error to just
Bad Request
So I went back to that ReplyUrl and changed it to https://appname.azurewebsites.net/.auth/login/aad/callback and now it appears to work.
Note I also had to make sure I didn't have the site open in any other tabs before it started working
I had this issue when I switched an app from our company Azure over to a customer's Azure. In my case I'd forgotten to update the ida:ClientId, ida:AADInstance and ida:TenantId, which then meant that the value I'd set for ida:PostLogoutRedirectUri was ignored (I think) and instead my app redirected to localhost.
Once I changed those ida values to the values from the app settings and subscriptions settings on our customer's Azure it all worked as expected.
It took a while to track down all the values in Azure portal as they are all called something different, or aren't named at all:
ClientId can be found at Azure Active Directory > App Registrations > YourAppName. It's called 'Application ID' in Azure
Domain can be found on Azure Active Directory > Overview. It's currently in the top left in the format somename.onmicrosoft.com
TenantId this is the Azure AD instance ID, get that from Azure Active Directory > Properties and then it's called 'Directory ID'
I spent a lot of time trying to work out where the localhost port that was being redirected to was in the code, but it simply isn't there as far as I can see, so I have no idea how Azure was choosing what localhost address to redirect to!
You need to set another parameter in configuration that is replyUrl and assign to your web app, other wise it takes the url from which it was originated.
I was able to fix this by changing my Startup.Auth.cs file redirectUri from "https://localhost:44316/" to https://myapp.com/
I recently decided to change from using Windows Authentication for my internal web applications to Forms Authentication. I've not used the latter very much and one site explained you have to enable both Forms and Anonymous for this to work. The idea is to verify user passwords against an active directory then grant them access accordingly. I had this working just fine locally and when publishing to IIS 7.5 it still worked. It was just a basic Visual Studio project that would redirect to our homepage.
The problems arose when I tried accessing this same project securely with https, I included the full domain and it would load the new login page but when I clicked login it would do nothing. Since then I've scoured the web and found numerous mentions of this and that and tried many of them to no avail.
It was only later I created a blank project with a single button and one line of the code on the page to see if a post back had fired. After publishing I only enabled Anonymous Authentication in IIS and browsing to this basic test app using http when you clicked the button, false on the page changed to true - indicating a post back. Yet with https it just remains false. I think this may be why the active directory login wasn't working as it too had Anonymous enabled.
I'm still pretty new at the secure side of things but with the details passing over I have to use a secure connection just for the login then it can redirect to the usual applications we use internally.
I'd appreciate any thoughts you may have regarding this.
Thanks!
We use this configuration (anonymous IIS access, forms authentication, and https) successfully all of the time.
There are three things that you should do to track this issue down:
1) Verify that there are no javascript errors in the page that break the button (i.e. a javascript file not being delivered to the page)
2) Check the windows event logs for exceptions from asp.net/iis.
3) Install and run fiddler, select Fiddler Options... from the Tools menu, click on the HTTPS tab and ensure all of the checkboxes are checked, then run your website and look at the requests and responses, particularly when you press the button.
Each developer is running IIS on his own machine. We all sit in separate physical location.
One developer develops the code using: http://localhost:8054/connectToFacebook.aspx
another developer develops the code using: http://localhost:80/virtualDirectory/connectToFacebook.aspx
etc.
I'd like the Facebook Connect authentication to work for all the developers.
Generally, the connect mechanism (login button with ajax dialog) does not work from localhost, as it requires a domain name.
Is it possible to make the Connect mechanism work - when watching the webpage from localhost? (or must I run the webpage be a publicly accessible domain name like dyndns?)
this tutorial shows you how to use the c# sdk w/ localhost. Hope that helps.
the easiest way is to make every dev on the team use the same url.
if u r using fb c# sdk, u can continue to use differnt url by implementing your own IFacebookApplication and depending on the request url change the appid and appsecret.
Hi
I made a simple application in Silverlight to facebbok with the facebook C# SDK, and it runs fine in a localhost. I have published on a server and know start the problems. When I try to run the application from the facebook I get the this messege (405 - HTTP verb used to access this page is not allowed.)
anyone have any ideias of what is the problem ??
thanks
That sounds like server/IIS/Web server configuration. Try hosting the web site in an iframe locally and see if you can get there...
I followed all the instructions in the following links yet I am getting the following error
Errors while loading page from application
The URL http://zsswfacebooklocal.com:1940/Default.aspx/ did not respond.
Has any one successfully got a simple asp.net application tested on facebook from their localhost on local dev machine. I did update my host file to have local ip 127.0.0.0 point to a temp domain name like zsswfacebooklocal.com
I used the following tutorials but no luck so far. Please help. For FB asp.net application: http://fbtutorial.qsh.eu/section1/step1.aspx
For local host: http://www.stevetrefethen.com/wiki/Facebook%20application%20development%20in%20ASP.NET.ashx
The HOSTS workaround will only work if your app's render method set to IFrame, so double-check that.
On the other hand, if you require your render method to be FBML, then see my response in your other (similar) question:
vs2010 express asp.net c#: facebook asp.net application
If your app's render method is FBML, Facebook tries to load your website the same way anyone over the internet would, so you'd need to set your local website to be accessible to the internet.