Graph API Version

Application Accounts

Test accounts for a Facebook app. This edge lets you manage test users for your app.

Related guides

A Note on Updating

You can't update a test user using this edge, however you can update a test user using the /{test-user-id} node.

Reading

Test accounts for this app

Permissions

  • An app access token for the app in the request is required.
Graph API Explorer
GET /v2.10/{application-id}/accounts HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{application-id}/accounts'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
/* make the API call */
FB.api(
    "/{application-id}/accounts",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{application-id}/accounts",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{application-id}/accounts"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Parameters

NameDescription
type
enum{test-users}

The type of user requested

Fields

Reading from this edge will return a JSON formatted result:

{ "data": [], "paging": {} }

data

A list of TestAccount nodes.

The following fields will be added to each node that is returned:

FieldDescription

access_token

string

An access token that can be used to make API calls on behalf of this user

paging

For more details about pagination, see the Graph API guide.

Validation Rules

ErrorDescription
200Permissions error
100Invalid parameter

Creating

By publishing to this edge you can create new test users and you can assosciate existing test users with new apps.

Permissions

  • An app access token is required to create new test users for an app.
  • If associating existing test users with new apps, app access tokens are required for both the app that created the test user, and the app that is being newly associated to the test user (see the owner_access_token parameter for more information).

Return values

  • The login_url return value can be used to log in as the test user. The URL will expire one hour after it's generated or after it's first used.
  • The access_token return value is only returned when the installed parameter is set to true.
You can make a POST request to accounts edge from the following paths:
When posting to this edge, a TestAccount will be created.

Parameters

NameDescription
installed
boolean

Automatically installs the app for the test user once it is created or associated

minor
boolean

Is this test user a minor

name
string

The name for the test user. When left blank, a random name will be automatically generated

owner_access_token
string

When associating existing test users with other apps, this is the app access token of any app that is already associated with the test user. The {app-id} in the publishing request in this case should be the app that will is the target to associate with the test user. The API request should also be signed with the app access token of that target app. Required when associating test users, but should not be used when creating new test users

permissions
List<Permission>
Default value: Set

List of permissions that are automatically granted for the app when it is created or associated

type
enum{test-users}

Type

uid
int

ID of an existing test user to associate with another app. Required when associating test users, but should not be used when creating new test users

Return Type

This endpoint supports read-after-write and will read the node represented by id in the return type.
Struct {
id: numeric string,
access_token: string,
login_url: string,
email: string,
password: string,
}

Validation Rules

ErrorDescription
2900Too many test accounts
100Invalid parameter
195The name you are trying to use is invalid

Updating

You can't perform this operation on this endpoint.

Deleting

You can't delete a test user using this edge. If you want to delete a test user use the /{test-user-id} node.

This edge will let you disassociate a test user from an app.

Permissions

  • The associated app access token is required to disassociate a test user.
  • A test user must still be associated with any single app after this operation, otherwise an error message (2902) will be shown.
You can dissociate a TestAccount from an Application by making a DELETE request to /{application_id}/accounts.

Parameters

NameDescription
type
enum{test-users}

Account type

uid
int

Account UID

Required

Return Type

Struct {
success: bool,
}

Validation Rules

ErrorDescription
100Invalid parameter
2901Invalid test account id
2902Cannot remove test account from this app
2904Cannot delete the OG Test User