Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel 6 posts 75 karma points
    Dec 16, 2015 @ 00:45
    Daniel
    0

    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?

  • Anders Bjerner 457 posts 2693 karma points MVP 5x admin c-trib
    Dec 16, 2015 @ 16:29
    Anders Bjerner
    1

    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 ;)

  • Daniel 6 posts 75 karma points
    Dec 16, 2015 @ 20:11
    Daniel
    0

    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(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;
    
  • Daniel 6 posts 75 karma points
    Dec 17, 2015 @ 02:14
    Daniel
    0

    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);

  • Anders Bjerner 457 posts 2693 karma points MVP 5x admin c-trib
    Dec 17, 2015 @ 08:19
    Anders Bjerner
    0

    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 ;)

  • Daniel 6 posts 75 karma points
    Dec 17, 2015 @ 20:32
    Daniel
    0

    Here is the code for authorization url:

        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.

    The Facebook app is set to public.

    enter image description here

  • Biagio Paruolo 1504 posts 1645 karma points c-trib
    Jun 24, 2016 @ 14:42
    Biagio Paruolo
    0

    Any update?

  • Anders Bjerner 457 posts 2693 karma points MVP 5x admin c-trib
    Jun 24, 2016 @ 20:05
    Anders Bjerner
    0

    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 ;)

Please Sign in or register to post replies

Write your reply to:

Draft