Skip to content

Issues with apiLogout() function #15

@Phillbaska

Description

@Phillbaska

First of all, a big thank you for making such a great wrapper. I haven't touched PHP in a while and this has made the process super easy.

I am however having an issue when attempting to explicitly logout from the filemaker data api after making a call.

Context
I'm only using the api to access data transactionally and don't want or need to be remain logged in. Specifically, what i'm trying to do is get a list of the clients connected to the filemaker server then delete/close the session after gathering this data.

My implementation
from the documentation/code i understand that an explicit call to delete/close the session is called via the function within the api object of apiLogout()

therefore my code reads as follows (no error handling added yet)

$aapi = new fmAdminAPI($host, $aapi_username, $aapi_password);
$client_list = $aapi->apiListClients();
$aapi_result = $aapi->apiLogout();

however, what i am finding is that line 3 is returning an error response. When echoing the result i get:

array(2) {
["response"]=> array(0) {}
["messages"]=> array(1) { [0]=> array(2) {
["code"]=> string(4) "1704"
["text"]=> string(48) "Resource doesn't support the specified HTTP verb"
}
}
}

debugging further, within the actual fmAdminApi.class.php file, i am adding the following line within the apiLogout() function before the curl command is called:

echo '<pre>' , $this->getAPIPath(PATH_ADMIN_LOGOUT).'/'. $this->getToken() , '</pre>'

this then reveals that the token is not being added to the url.

https://{my host}/fmi/admin/api/v2/user/auth/

then looking at fmAPI.class.php it appears that getToken() sources the admin api's "token" key.

given the above url missing the token, i assumed that the token does not exist or that key is empty which on echo of the admin api object i discovered i was correct:

(shortened version with sensitive details redacted)

Object(fmAdminAPI)#1 (24) {
["cloud"]=> bool(false)
["convertBooleanStrings"]=> bool(true)
["userName"]=> NULL
["password"]=> NULL
["storeUNPW"]=> bool(false)
["host"]=> string(25) "https://{my host}"
["credentials"]=> string(48) "{base64StringOfPassword}"
["sendCredentialsIfNoToken"]=> bool(true)
["token"]=> string(0) ""
["tokenTimeStamp"]=> int(0)
["storeTokenInSession"]=> bool(true)
["sessionTokenKey"]=> string(22) "FM-Admin-Session-Token"
["tokenFilePath"]=> string(0) ""

Is there another setting im missing that needs to be applied to retain the token so it can be used to logout?

Thanks again
Phill

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions