Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with apiLogout() function #15

Open
Phillbaska opened this issue Apr 8, 2023 · 2 comments
Open

Issues with apiLogout() function #15

Phillbaska opened this issue Apr 8, 2023 · 2 comments

Comments

@Phillbaska
Copy link

Phillbaska commented Apr 8, 2023

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

@Phillbaska
Copy link
Author

it's worth noting i've worked around this by adding an explicit call to apiLogin() before my call to get the client list which resolves the issue (stores the token in the admin api object)

so perhaps its an assumption on my part that the wrapper should be saving the token if auto login occurs (when calling api without explicitly logging in)

@Phillbaska Phillbaska changed the title Issues with apLogout() function Issues with apiLogout() function Apr 8, 2023
@driftwoodinteractive
Copy link
Owner

driftwoodinteractive commented Feb 7, 2024

I'm unable to reproduce this - apiLogout() does indeed send the token. You can call apiListClients() without needing to login first as the code takes care of calling login for you (and handling the token management).

Have you looked at the debug log output to see if there's anything curious going on?

Repository owner deleted a comment from osw17 Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants