Upgrading Reports to v3

I am using PAT to access:

from a scheduled job on our CRM to retrieve Chats and log them against our own customer data. Date limits and pagination give me what I need and it is working well BUT it is a v2 API which I believe is deprecated.

I did try to avoid v2 APIs and use

but it is my understanding that PAT does not work for v3.
And hard as I tried I could NOT get authentication working from the scheduler, which is effectively a PHP script run by a Cron job.

I guess my problem is I don’t know how to handle redirects in a scheduler PHP script.

Can anyone help with that?

Thank you,
LiveChat Beginner… in case you had not noticed :smile:

Your PAT is going to work with both v2 and v3 API, but you will need to provide different login when authenticating :slight_smile:
You can find all the necessary details in Developers console in Personal access token section

as visible on the screenshot.



Let me know if that works! :smiley:

Thank you Łukasz, unfortunately it is not working for me.

I am using the following, where
$username = “myAccountID:dal:myPAT”;
And I am calling it with a blank oauthtoken

This does not work:

But this does where token is returned by my agent widget:

Note that this same function works great when called w/ a token from the Agent Dashboard, but in this case I am trying to use it without Agent intervention

I believe my PAT has the right scopes.

The error is:
{“error”:{“type”:“authentication”,“message”:“Invalid access token”}}

It looks like you are using PAT as bearer token, which won’t work. Access Tokens generated through our Authorization process are bearer tokens, but not PATs.

It should be Basic Auth with login: {{Account ID}} and password: {{PAT}}

No, I’m not, if you look at the if-else statement I am using Bearer token for the api triggered by the user interface, where the oauthtoken parameter in the function call is filled in, but I am using CURLOPT_USERPWD, which is equivalent to the Basic auth you mention, in the else statement which is how I call the api when I do not have an oauthtoken as is this example.

Sorry for missing that! Just to be sure we have tested this method internally with PATs, but there are no issues there.The error suggests an issue with the authorization and I noticed you wrote this: $username = "myAccountID: dal:myPAT "; as PAT already includes the prefix dal: can you please check whether your end result does not include this prefix twice?

I added that to show I explicitly include the “dal:” but yes, I can confirm that I only include it once.

If it looks correct on your end I will do some more testing, maybe delete the PAT and generate a new one to make sure I have copied it correctly.

Thank you for checking.

Hey, have you done some more testing with a new PAT? How it goes?

Thank you for following up - no, I’ve not done more, I’ve been swamped with other projects. I’ll update here once I do though :slight_smile:

1 Like