Egydeveloper
Egydeveloper

Reputation: 195

error Missing client_id parameter by asp.net?

I had this error when getting Facebook user details .

{    
    "error": {
    "message": "Missing client_id parameter.",
    "type": "OAuthException",
    "code": 101    } 
 }

I will use this solution when user click on Facebook tab. I tried to solve this issue more but I cannot .

public partial class DefaultPage : System.Web.UI.Page
{ 

    protected void Page_Load(object sender, EventArgs e)
    {
        FaceBookConnect.Authorize("user_photos,email",            
        Request.Url.AbsoluteUri.Split('?')[0]); 
        FaceBookConnect.API_Key = "111111111111111";
        FaceBookConnect.API_Secret = "xxxxxxxxxxxxxxxxxx";


            if (Request.QueryString["error"] == "access_denied")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('User has denied access.')", true);
                return;
            }

            string code = Request.QueryString["code"];
            if (!string.IsNullOrEmpty(code))
            {
                string data = FaceBookConnect.Fetch(code, "me");
                FaceBookUser faceBookUser = new JavaScriptSerializer().Deserialize<FaceBookUser>(data);
                faceBookUser.PictureUrl = string.Format("https://graph.facebook.com/{0}/picture", faceBookUser.Id);
                pnlFaceBookUser.Visible = true;
                //lblId.Text = faceBookUser.Id;
                //lblUserName.Text = faceBookUser.UserName;
                lblName.Text = faceBookUser.Name;
                //lblEmail.Text = faceBookUser.Email;
                ProfileImage.ImageUrl = faceBookUser.PictureUrl;
                //btnLogin.Enabled = false;
          }
        }
    }

public class FaceBookUser
{
    public string Id { get; set; }
    public string Name { get; set; }
    public string UserName { get; set; }
    public string PictureUrl { get; set; }
    public string Email { get; set; }
}

Thanks!

Upvotes: 0

Views: 1209

Answers (1)

mattmanser
mattmanser

Reputation: 5796

I suspect it will be because you're setting the API Key and secret after you are actually calling the authorize method. Try swapping it round like this:

FaceBookConnect.API_Key = "111111111111111";
FaceBookConnect.API_Secret = "xxxxxxxxxxxxxxxxxx";

FaceBookConnect.Authorize("user_photos,email",            
Request.Url.AbsoluteUri.Split('?')[0]); 

If this doesn't fix it, where are you getting the FaceBookConnect reference from?

Upvotes: 1

Related Questions