Closed chijinbo closed 4 years ago
Hi @chijinbo
I just tried this using our starter app and was able to retrieve the "sid"
Give that a try.
Hi @SidneyAllen
Thank you for your reply. I tested with starter APP, the 'sid' can be retrieved successfully. However, I still can't retrieve it from my laravel project. I also can confirm all other parts, like API authorisation and API call, are working as expected. I will do some deep investigation to see why there is no 'sid' in my project. Thank you.
Hi @SidneyAllen
I am using this package on my laravel app: https://github.com/webfox/laravel-xero-oauth2
My initial idToken includes the 'sid' value. The idToken on the next request does not include the 'sid' and therefore the decode() function fails.
found in \xeroapi\xero-php-oauth2\lib\JTWClaims.php
I have commented this out for now.
// $this->sid = $this->jwtDecoded->{'sid'};
Not sure what the 'sid' value is used for or why its not included?
Hi @SidneyAllen,
Using webfox/laravel-xero-oauth2 when requesting the user to display who has authenticated the connection to an organisation the sid is not in the resulting refresh token/response.
Steps to reproduce this are:
This is done easily by implementing the example XeroController with this snippet of php:
$xero = resolve(\XeroAPI\XeroPHP\Api\AccountingApi::class);
$organisations = $xero->getOrganisations($xeroCredentials->getTenantId());
$organisationName = $organisations->getOrganisations()[0]->getName();
$user = $xeroCredentials->getUser(); // error occurs in this call while refreshing token
$username = "{$user['given_name']} {$user['family_name']} ({$user['username']})";
As mentioned by @Daafie the exception is specifically thrown here: https://github.com/XeroAPI/xero-php-oauth2/blob/e6881e29e766cb0b2ab8819631dbe4cbb6db6402/lib/JWTClaims.php#L45
Please let me know any information or feedback to assist in getting this resolved.
@conormx - I've released version 2.1.6 of xero-php-oauth2 SDK with your PR merged
SDK you're using:
Describe the bug The jwtDecoded didn't return $sid.
To Reproduce Using the example code below,
` // Decode JWT $jwt = new XeroAPI\XeroPHP\JWTClaims(); $jwt->setTokenId($accessToken->getValues()["id_token"]); // Set access token in order to get authentication event id $jwt->setTokenAccess($accessToken->getToken()); $jwt->decode();
$sub = $jwt->getSub(); $iss = $jwt->getIss(); $exp = $jwt->getExp(); $given_name = $jwt->getGivenName(); $family_name = $jwt->getFamilyName(); $email = $jwt->getEmail(); $user_id = $jwt->getXeroUserId(); $username = $jwt->getPreferredUsername(); $session_id = $jwt->getGlobalSessionId(); $authentication_event_id = $jwt->getAuthenticationEventId();`
Expected behavior No error should occur
When dumping jwtDecoded, there is no sid in the result.