Open Duncan-dev1 opened 3 years ago
I am also facing error while getting a single contact.
I have scopes accounting.transactions accounting.contacts
added in my request.
My $this->xero is returning the xero object successfully.
but code
$contact = $this->xero->contacts()->find($xero_auth->contact_id);
is returning error.
XeroPHP\Remote\Exception\ForbiddenException: You are not permitted to access this resource in /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Remote/Response.php:127
Stack trace:
#0 /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Remote/Request.php(119): XeroPHP\Remote\Response->parse()
#1 /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Application.php(200): XeroPHP\Remote\Request->send()
#2 /var/www/html/project_dev/vendor/langleyfoxall/xero-laravel/src/Wrappers/QueryWrapper.php(102): XeroPHP\Application->loadByGUID('\\XeroPHP\\Models...', 'xxxxxxxx-xxxx-x...')
$contact = $this->xero->contacts()->find($xero_auth->contact_id);
Is never going to work. You are asking $xero_auth to provide the contact id, which it doesn't have as you are asking it to find one. Need to change the text inside find to a valid Xero contact UUID the organisation has access too.
Hello,i am new to Xero and i am trying to get my head around how to go about things,i am asking this here because i have exhausted my options .So i did everything well since i can get my app to request and get access tokens and tenant ID and choose an app from xero,thanks to a flawless documentation.When i got to the usage section,i created a route ;'about' just to test things and pasted this to its controller `public function about() { $user = auth()->user();
$xero = new XeroApp( new AccessToken(json_decode($user->xero_oauth_2_access_token)), $user->xero_tenant_id ); $contacts = $xero->contacts()->get(); dd($contacts); }` trying to access the about page,i get this error: Argument 1 passed to League\OAuth2\Client\Token\AccessToken::__construct() must be of the type array, null given, called in C:\xampp\htdocs\foodiez\app\Http\Controllers\HomeController.php on line 88 what could i be doing wrong. Also to anyone who will respond to this,how do we add a contact to xero with the syntax offered by this package
Issue here is refreshing the token, start on that first. Then the second issue is the code you are using is for getting a contact, not adding one.
Hello,i am new to Xero and i am trying to get my head around how to go about things,i am asking this here because i have exhausted my options .So i did everything well since i can get my app to request and get access tokens and tenant ID and choose an app from xero,thanks to a flawless documentation.When i got to the usage section,i created a route ;'about' just to test things and pasted this to its controller
public function about() { $user = auth()->user(); $xero = new XeroApp( new AccessToken(json_decode($user->xero_oauth_2_access_token)), $user->xero_tenant_id ); $contacts = $xero->contacts()->get(); dd($contacts); }
trying to access the about page,i get this error: Argument 1 passed to League\OAuth2\Client\Token\AccessToken::__construct() must be of the type array, null given, called in C:\xampp\htdocs\foodiez\app\Http\Controllers\HomeController.php on line 88 what could i be doing wrong. Also to anyone who will respond to this,how do we add a contact to xero with the syntax offered by this packageIssue here is refreshing the token, start on that first. Then the second issue is the code you are using is for getting a contact, not adding one.
Thank you,but how does a refresh code look like on the default,because i havent done anything myself,just the configuration as per the guidelines.I got the error while trying to get contacts.Sorry to bother you
Its literaaly on the front page as a function in the code block where you got the first part. here
The token lasts 30 minutes, so you need to ensure you are refreshing the token to maintain access.
Yes it is, i have to set that up some more? Call it in a way? I actually thought the package handles everything from authorization to storing the access token to refreshing the token. If you have a few minutes maybe you can show me a demo on what goes in where and how do i get a contact maybe
On Wed, May 5, 2021, 11:17 PM Seán McCabe @.***> wrote:
Its literaaly on the front page as a function in the code block where you got the first part. here https://github.com/langleyfoxall/xero-laravel#oauth-20-flow
The token lasts 30 minutes, so you need to ensure you are refreshing the token to maintain access.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/langleyfoxall/xero-laravel/issues/45#issuecomment-832978439, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZM7BOUXTX3UXX2RXCY7TLTMGRUXANCNFSM44DVNXPQ .
Yes you need to call that function, safest is to call it before every Xero connection so ensure you have an active token.
No it doesn't. It just gives you an easy way to handle that stuff, rather than re-inventing the wheel everytime. You need to sort the storing of the token and tenant id etc. (i.e. in a database or something) to call later.
All the code you need is on the frontpage, and it assumes you have a basic knowledge of laravel and PHP to then know how to store the data you've gotten.
It's clearer now what i am expected to do. Incase of more clarifications can i still reach out? Thank you
On Wed, May 5, 2021, 11:35 PM Seán McCabe @.***> wrote:
Yes you need to call that function, safest is to call it before every Xero connection so ensure you have an active token.
No it doesn't. It just gives you an easy way to handle that stuff, rather than re-inventing the wheel everytime. You need to sort the storing of the token and tenant id etc. (i.e. in a database or something) to call later.
All the code you need is on the frontpage, and it assumes you have a basic knowledge of laravel and PHP to then know how to store the data you've gotten.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/langleyfoxall/xero-laravel/issues/45#issuecomment-832989106, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZM7BLUM3KQ7UWIBYMR3ATTMGTXNANCNFSM44DVNXPQ .
@seanmccabe My system has the correct contact id in $xero_auth as it is object of my db modal getting contact id from database.
@seanmccabe My system has the correct contact id in $xero_auth as it is object of my db modal getting contact id from database.
The error says you dont have permission to access that resource. So are you sure that contact uuid is within the tenant you have authorised and are passing through?
@seanmccabe My system has the correct contact id in $xero_auth as it is object of my db modal getting contact id from database.
The error says you dont have permission to access that resource. So are you sure that contact uuid is within the tenant you have authorised and are passing through?
Yes I have added that contact using that tanant and with package only but when I am trying to access that contact to add the invoice it is giving me the error I mentioned above.
I am also facing error while getting a single contact.
I have scopes
accounting.transactions accounting.contacts
added in my request.My $this->xero is returning the xero object successfully. but code
$contact = $this->xero->contacts()->find($xero_auth->contact_id);
is returning error.
XeroPHP\Remote\Exception\ForbiddenException: You are not permitted to access this resource in /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Remote/Response.php:127 Stack trace: #0 /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Remote/Request.php(119): XeroPHP\Remote\Response->parse() #1 /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Application.php(200): XeroPHP\Remote\Request->send() #2 /var/www/html/project_dev/vendor/langleyfoxall/xero-laravel/src/Wrappers/QueryWrapper.php(102): XeroPHP\Application->loadByGUID('\\XeroPHP\\Models...', 'xxxxxxxx-xxxx-x...')
Did you manage to solve your errors?can i email you to help me a little?
The errors aren't code related, you are trying to access a resource you don't have permission to view. It is connecting to Xero, or you wouldnt get that error.
So either: 1) You have the wrong tenant or contact ID 2) You are not passing the tenance or contact ID correctly
This may be of help: https://github.com/calcinai/xero-php/issues/753
Hello,i am new to Xero and i am trying to get my head around how to go about things,i am asking this here because i have exhausted my options .So i did everything well since i can get my app to request and get access tokens and tenant ID and choose an app from xero,thanks to a flawless documentation.When i got to the usage section,i created a route ;'about' just to test things and pasted this to its controller `public function about() { $user = auth()->user();
$xero = new XeroApp( new AccessToken(json_decode($user->xero_oauth_2_access_token)), $user->xero_tenant_id ); $contacts = $xero->contacts()->get(); dd($contacts); }` trying to access the about page,i get this error: Argument 1 passed to League\OAuth2\Client\Token\AccessToken::__construct() must be of the type array, null given, called in C:\xampp\htdocs\foodiez\app\Http\Controllers\HomeController.php on line 88 what could i be doing wrong. Also to anyone who will respond to this,how do we add a contact to xero with the syntax offered by this package