开发者

FB c# SDK permissions?

开发者 https://www.devze.com 2023-04-06 03:11 出处:网络
I\'m developing a FB MVC3 site using the FB c# SDK. In my controller is this line private const string ExtendedPermissions = \"user_about_me,publish_stream\";

I'm developing a FB MVC3 site using the FB c# SDK.

In my controller is this line private const string ExtendedPermissions = "user_about_me,publish_stream";

in the logon method is this line: if (fbWebContext.IsAuthorized(ExtendedPermissions.Split(',')))

it always returns false even though I have an access token so I traced into the source code...

bool isAuthorized = IsAuthenticated(); returns true so user is authorized. Then it checks for permissions starting with this call var currentPerms = HasPermissions(AccessToken, Settings.AppId, UserId, permissions);

it returns a single entry with the value "installed". This makes no sense as you will see later. Keep reading...

Then it loops through checking the passed permissions against the FB permissions like so: foreach (var perm in permissions) { if (!currentPerms.Contains(perm)) { return false; } } of course it returns false as it should because the permissions user_about_me and publish_stream are not in the FB permissions. However, I go to the apps in FB and it shows this

Access my basic information Includes name, profile picture, gender, networks, user ID, list of friend开发者_StackOverflow社区s, and any other information I've shared with everyone.

So my question is : What does "installed" mean? and shouldn't it return user_about_me?

so shouldn't the line above var currentPerms = HasPermissions(AccessToken, Settings.AppId, UserId, permissions);

return "user_about_me". Yet it only returns the word "installed"

So I know why it is failing, but logic tells me it shouldn't fail. It has something to do with accessing FB permissions for the user.

Has anyone else seen this or have an answer?

Many Thanks


I tried FB C# SDK 5.2.1 and I had a problem with HasPermission. But searched here and found your -very actual- question. FacebookWebContext.Current.HasPermission("user_about_me") in my case returns false. But FacebookWebContext.Current.IsAuthorized("user_about_me") returns true.

I tried with

if (FacebookWebContext.Current.IsAuthorized("publish_stream"))

and to me it returns true.

I also tried your split method, to check if it was ok to check more permissions at once, and it was also returning true.

Hint: try the last SDK version and try using FacebookWebContext.Current instead "fbWebContext" (which makes me think has something wrong).


Had the same issue, and resolved it as a viewbag item wasn't set.

Check the permisions/scope being passed to facebook.

I had to add

ViewBag.ExtendedPermissions = ExtendedPermissions;

in order for it to render in the javascript and passthrough.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号