1

We are trying to create Facebook test users using the Facebook iOS SDK 3.14.1 according to their website: https://developers.facebook.com/docs/graph-api/reference/v2.0/app/accounts/test-users

Here is our code:

NSString *fbAccessToken = [NSString stringWithFormat:@"%@",FBSession.activeSession.accessTokenData];

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                        @"true", @"installed",
                        fbAccessToken, @"owner_access_token",
                        nil
                        ];



NSString *path = [NSString stringWithFormat:@"/%@/accounts/test-users", kFacebookID];

/* make the API call */
[FBRequestConnection startWithGraphPath:path        ///{app-id}/accounts/test-users"
                             parameters:nil
                             HTTPMethod:@"POST"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          )
                      {

                          if (result  && !error)
                          {
                              NSLog(@"Test-User created successfully: %@", result);
                          }
                          else
                          {
                              NSLog(@"Error creating test-user: %@", error);
                              NSLog(@"Result Error: %@", result);
                          }

                      }];

When we run it we receive the following error:

    error =         {
        code = 15;
        message = "(#15) This method must be called with an app access_token.";
        type = OAuthException;
    };

We have also tried without the parameter owner_access_token but the same error occurs. How can we create Facebook Test users programmatically using the Facebook iOS SDK?

VSH
  • 7
  • 1
  • 7
  • You shouldn't. You have to use and app access token and you should never put an app access token in an app – WizKid Jun 04 '14 at 22:16

1 Answers1

-2

Solution:

Instead of using the active session access token in you should use the App Token. Just replace FBSession.activeSession.accessTokenData with your App Token.

The App Token can be found here: https://developers.facebook.com/tools/accesstoken/

As per WizKid comment above, this is for testing purposes only.

VSH
  • 7
  • 1
  • 7