Facebook API's fb:registration returning "Invalid 'client_id'" when not connected to Facebook
Asked Answered
E

6

6

I'm trying to use Facebook's registration tool for my website. I would like to allow Facebook users to login seamlessly to my website, but also non-Facebook users to create an account through that unified UI.

I'm using the <fb:registration> tag for that purpose. If I'm already connected to Facebook when arriving to the page, everything works as expected (the form is prefilled with information from my Facebook account). But if I'm not connected to Facebook, the following error is displayed: Invalid 'client_id'..

What am I doing wrong?

Thanks very much for your help.

You'll find below the HTML code rendered from the server:

<!doctype html>
<html xmlns:fb='http://www.facebook.com/2008/fbml'>
<head id='head'>
<title>MyWebSite - Signup</title>
<link rel='stylesheet' type='text/css' href='/client/Core.css'/>
<script language='JavaScript' type='text/javascript' src='/client/jQuery.js'></script>
<script type='text/javascript'>
function initialize() {
 $.getScript('client/Core.js');
 $.getScript(document.location.protocol + '//connect.facebook.net/en_US/all.js');
}

window.fbAsyncInit = function() {
 FB.init({
  appId   : 123456789, // replaced here by my App ID
  session : {},
  status  : true,
  cookie  : true,
  xfbml   : true
 });
 FB.Event.subscribe('auth.login', function() {
  window.location.href = 'DoLogin';
 });
};
</script>
</head>
<body onload='initialize();'>
<span id='fb-root'></span>
<fb:registration 
    fields='[{"name":"name"},{"name":"first_name"},{"name":"last_name"},{"name":"email"},{"name":"location"},{"name":"gender"},{"name":"password","view":"not_prefilled"},{"name":"captcha"}]' 
    redirect-uri='http://172.16.100.31/DoSignup'
    width='600'
    fb_only='false'
    allowTransparency='true'>
</fb:registration>
</body>
</html>
Equites answered 30/1, 2011 at 21:42 Comment(0)
B
12

You might have to configure your application to let users other than the developers to access the app. I had a hard time finding it, but if I remember well, it was a matter of sandboxing the app or not.

Bruno answered 16/2, 2011 at 20:32 Comment(5)
Thank you very much, that was it! That makes sense, but the ambiguous error message doesn't really help...Equites
In your app on the developer page, go to About->Advanced->Authentication->Sandbox Mode and click Disabled. I enabled this thinking it'd be fine since I only want developer access, but I guess that's incompatible with registation! Silly me.Johanna
OMG this was killing us - thank you so much! This was a real doh! moment.Iggy
and sandbox was the solution.Shopkeeper
Phew, thanks for that. Facebook and their lack of documentations!Microampere
W
2

I ran into the same problem, except I had the sandbox disabled already. I had included the script tag as

<script src="http://connect.facebook.net/en_US/all.js#appId={YOUR_APP_ID}&xfbml=1"></script>

<fb:registration 
  fields="name,birthday,gender,location,email" 
  redirect-uri="https://developers.facebook.com/tools/echo/"
  width="530">
</fb:registration>

as it was on the registration example page, however, the JavaScript SDK page had

<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({
    appId  : 'YOUR APP ID',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
</script>

Removing the #appId={YOUR_APP_ID}&xfbml=1 from the external script tag did the trick.

Willettawillette answered 12/5, 2011 at 14:57 Comment(0)
F
0

If you registered your application with Facebook they will give you an appID which you will need to use instead of the '123456789' AppID in the code above.

Footage answered 1/2, 2011 at 4:39 Comment(1)
Thanks for your answer, but I already own a Facebook app ID, which I'm using instead of the "123456789" above. I was using this fake number just to avoid giving out my app ID. Other than that, do you see anything wrong in the code above? If you own an app ID, could you copy/paste this code and try it out with your app ID?Equites
A
0

Just guessing here - because I had a similar but non-identical problem:

If you use the Facebook XFBML code on http://developers.facebook.com/docs/plugins/registration/ and replace the word {YOUR_APP_ID} by {1234123434534} (or whatever), it fails because it isn't expecting the curly brackets. (Different from various other areas that use JSON and are expecting them).

I don't know if this is what you've done wrong, but it's an easy mistake to make, as I just discovered.

Ambassadress answered 24/2, 2012 at 15:10 Comment(0)
T
0

For testing set your YOUR_APP_ID to 113869198637480

Teem answered 16/5, 2012 at 6:20 Comment(0)
B
0

In my case, I was displaying the fb registration link without logging in the user first. After scratching my head for a long time, I asked the user to log in through facebook before presenting the registration form. The error was gone much to my delight.

Backhanded answered 16/3, 2014 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.