I can't remember the error messages exactly, but I think this error happens somewhere either before or after the code you have posted. If you can post some more of your code - and possible a stack trace of the exception - I can have a look at it ;)
{"Message":"An error has occurred.","ExceptionMessage":"(#100) You must provide an app access token or a user access token that is an owner or developer of the app","ExceptionType":"Skybrud.Social.Facebook.Exceptions.FacebookException","StackTrace":" at OurDateNite.ControllerLogic.FacebookFacade.ProcessCallback(Dictionary2 queryStrings)\r\n at OurDateNite.Controllers.API.FacebookApiController.ProcessLoginCallback()\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)"}
Here is the code after trying to create the service:
var service = FacebookService.CreateFromAccessToken(accessToken);
// get facebook user details
var fbGetUserOptions = new FacebookGetUserOptions("me") { Fields = "name, first_name, last_name, email" };
var getUserResponse = service.Users.GetUser(fbGetUserOptions);
var facebookId = getUserResponse.Body.Id;
var firstName = getUserResponse.Body.FirstName;
var lastName = getUserResponse.Body.LastName;
var email = getUserResponse.Body.Email;
// get token details
var getDebugTokenResponse = service.Debug.DebugToken(accessToken);
var accessTokenTimeout = getDebugTokenResponse.Body.Data.ExpiresAt;
Based on the code you have posted, I'm not sure why you're seeing this error, but something somewhere goes wrong with your access token.
Your stack trace doesn't mention any of the classes from Skybrud.Social. Do you by any chance catch the exception, and then throw a new once?
The code example in your second last post starts with initializing an instance of FacebookService from your access token. The problem however seems that your access token is invalid (or just of the wrong type), so if you can post some more information about how you got the access token, that would be a great help.
The code example in your last post doesn't mention doesn't use the classes in Skybrud.Social - at least not directly - so I can't tell what's going on there.
The more details you can provide, the better chance I have for figuring out what goes wrong ;)
public string GetAuthorizationUrl(FacebookOAuthClient client, string originUrl)
{
var state = originUrl;
var scope = new FacebookScopeCollection(FacebookScope.Email);
return client.GetAuthorizationUrl(state, scope);
}
Here is the code getting the access toekn:
public string GetAccessTokenFromAuthCode(FacebookOAuthClient client, string authCode)
{
var accessToken = client.GetAccessTokenFromAuthCode(authCode);
return accessToken;
}
Here is the code for getting the user details:
var service = FacebookService.CreateFromAccessToken(accessToken);
// get facebook user details
var fbGetUserOptions = new FacebookGetUserOptions("me") { Fields = "name, first_name, last_name, email" };
var getUserResponse = service.Users.GetUser(fbGetUserOptions);
var facebookId = getUserResponse.Body.Id;
var firstName = getUserResponse.Body.FirstName;
var lastName = getUserResponse.Body.LastName;
var email = getUserResponse.Body.Email;
// get token details
var getDebugTokenResponse = service.Debug.DebugToken(accessToken);
var accessTokenTimeout = getDebugTokenResponse.Body.Data.ExpiresAt;
It's strange that I can login fine as the Facebook app admin account. BUt when I try log in as anybody else it throws this error.
Not really, sorry. I think I've missed Daniel's reply back in December, but I just had another look at it, but really can't reproduce the error.
@Daniel Are you even using the Umbraco package for handling login? Based on some of your code, it seems that you're handling login on your own, and that it's somewhere along the way that you get an invalid access token. With the code provided so far, I cant really say much about what goes wrong.
@Biago If you can provide some more information about your case, I'd be happy to look more into that as well ;)
Skybrud social Facebook login
I am using SKybrud to login via Facebook.
var authCode = Request.QueryString["code"]; var accessToken = client.GetAccessTokenFromAuthCode(authCode);
var service = FacebookService.CreateFromAccessToken(accessToken);
When trying to create the service the following error occurs:
You must provide an app access token or a user access token that is an owner or developer of the app
I logs in only for developers of the app. Is there some setting to allow any user token not only developers and ownser?
Hi Daniel,
I can't remember the error messages exactly, but I think this error happens somewhere either before or after the code you have posted. If you can post some more of your code - and possible a stack trace of the exception - I can have a look at it ;)
Here is the stack trace:
{"Message":"An error has occurred.","ExceptionMessage":"(#100) You must provide an app access token or a user access token that is an owner or developer of the app","ExceptionType":"Skybrud.Social.Facebook.Exceptions.FacebookException","StackTrace":" at OurDateNite.ControllerLogic.FacebookFacade.ProcessCallback(Dictionary
2 queryStrings)\r\n at OurDateNite.Controllers.API.FacebookApiController.ProcessLoginCallback()\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func
1 func, CancellationToken cancellationToken)"}Here is the code after trying to create the service:
var service = FacebookService.CreateFromAccessToken(accessToken);
this is the code used for the setup and request to facebook:
_fbOAuthClient = FacebookOAuthClientFactory.Get(FbSettings.FacebookAppId, FbSettings.FacebookAppSecret, ApplicationUriResolver.ApplicationBaseUri + FbSettings.FacebookLoginCallbackApi);
var authorizationUrl = FacebookOAuthManager.GetAuthorizationUrl(FbOAuthClient, nextLocation);
Based on the code you have posted, I'm not sure why you're seeing this error, but something somewhere goes wrong with your access token.
Your stack trace doesn't mention any of the classes from Skybrud.Social. Do you by any chance catch the exception, and then throw a new once?
The code example in your second last post starts with initializing an instance of
FacebookService
from your access token. The problem however seems that your access token is invalid (or just of the wrong type), so if you can post some more information about how you got the access token, that would be a great help.The code example in your last post doesn't mention doesn't use the classes in Skybrud.Social - at least not directly - so I can't tell what's going on there.
The more details you can provide, the better chance I have for figuring out what goes wrong ;)
Here is the code for authorization url:
Here is the code getting the access toekn:
Here is the code for getting the user details:
It's strange that I can login fine as the Facebook app admin account. BUt when I try log in as anybody else it throws this error.
The Facebook app is set to public.
Any update?
Not really, sorry. I think I've missed Daniel's reply back in December, but I just had another look at it, but really can't reproduce the error.
@Daniel Are you even using the Umbraco package for handling login? Based on some of your code, it seems that you're handling login on your own, and that it's somewhere along the way that you get an invalid access token. With the code provided so far, I cant really say much about what goes wrong.
@Biago If you can provide some more information about your case, I'd be happy to look more into that as well ;)
is working on a reply...