(Facebook C# SDK) Problem getting an access token

前端 未结 3 1861
面向向阳花
面向向阳花 2021-01-22 12:01

I\'m quite new to the Facebook C# SDK (5.0.3) which probablly is the reason for this question. Basically, I\'m trying to get the current users profile, email, photo, etc etc. B

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-22 12:28

    You code is correct for the most part, the only piece you were missing was the "redirect_uri" parameter when calling the "ExchangeCodeForAccessToken" method. This has to match the App URL you set up when you registered your Facebook App. Otherwise, you will get the error you were receiving. You don't need the "permissions" parameter, you have already received that during the prior authorization.

     Dictionary parameters = new Dictionary();
     parameters.Add("redirect_uri", "http://www.yourcallbackurl.com/");
     var result = cl.ExchangeCodeForAccessToken(result.code,parameters);
    

提交回复
热议问题