parse-php-sdk icon indicating copy to clipboard operation
parse-php-sdk copied to clipboard

Unauthorized error when trying to access parse custom hosted server

Open marcgug opened this issue 10 years ago • 4 comments

Hi,

Since Parse is shutting down, I am trying to follow the migration guide to setup my own parse server. I have the server setup and working (because I can access the data via CURL requests), however, it seems like the php-sdk is not working correctly because I always get the following error:

Fatal error: Uncaught exception 'Parse\ParseException' with message 'unauthorized' in /home2/marc/public_html/oyster_admin/vendor/parse/php-sdk/src/Parse/ParseClient.php:346

Does this possibly have to do with the fact that only the AppID is required for parse server instances and the php-sdk initialization requires the AppID, RestKey, and MasterKey?

marcgug avatar Feb 03 '16 16:02 marcgug

This is because the php-sdk assumes that the parse server always lives at api.parse.com. There is currently no way to override that (except for modifying it manually in ParseClient.php).

marcgug avatar Feb 03 '16 17:02 marcgug

What to modify in parseclient.php

ghost avatar Feb 03 '16 18:02 ghost

HOST_NAME on line 19 needs to be changed from api.parse.com to the url of your custom server.

You also need to remove the references to the /API_VERSION on lines 470 and 302.

There really should be an update made to this repo to support specifying a custom hostName in the initialization function. If I have time, I will open a PR for that.

marcgug avatar Feb 03 '16 18:02 marcgug

Updated in 1.2.0, see #222

gfosco avatar Feb 17 '16 00:02 gfosco