Just cloned the foxyclient-php-playground repo and got it running.
It loads at
http://localhost:8000, but when I try to view coupons or item categories, I get the "Unable to obtain fx:store href" error.
What is this telling me?
How do I fix it?
FYI:
I did register my client.
I added the client_id, client_secret, and refresh_token rcvd to the boostrap.php.
I also tried uncommenting the access_token and putting in the one I rcv'd, but that threw an additional error saying something like "incorrect access token".
I re-comment out that line, and that error went away.
Sorry to hear you're having troubles with the hAPI playground code - I've just quickly tried on my side and ran into the same problem. I'll discuss this with our API developer and someone will be back in touch soon!
Thanks for your patience! I've connected with our API developer and hopefully we can get you on the right track.
First off - what did you use to create the OAuth token? Did you use the example code as found here: https://github.com/FoxyCart/foxyclient-php-example to do that?
If so - the first thing to check there is that the
use_sandbox
boolean inbootstrap.php
is set tofalse
.You mentioned you created a client - did you also connect that client to your FoxyCart store? If not - on the foxyclient example set up with your client created, click "OAuth Authorization Code grant", leave the scope as "full_store_access" and click to "Authorise Application". This will redirect you to our OAuth endpoint where you can login using your FoxyCart admin credentials and select the store to connect to your OAuth client.
Once you select the store - that will redirect you back to the FoxyClient example script - and it's from that page that you would copy the
client_id
,client_secret
andrefresh_token
(you'll need to check the page source to get the last two). Paste those three values into the FoxyClient Playground script'sbootstrap.php
file, and again - ensure thatuse_sandbox
is set tofalse
.If you then load up the playground set up, you should be able to view the store's coupons.
Sorry for the confusion with getting our example scripts up and running. We're currently working through creating a better "getting started" experience for new users for our API.
2. Updated `use_sandbox` to `false` and tested. Failed.
3. I thought I followed the process all the way through connecting to our store (we have only one), but don't recall exactly what steps I saw after logging in with FoxyCart credentials.
4. I do know that I did not have to check page source to get any of the credentials. They were displayed all nice and orderly for me.
Is this difference because I went a different route for creating my OAuth token?
Or is there possibly an additional step that is needed from me?
NOTE:
In case it helps .. when I visit http://localhost:8000/coupons.php?action=view_coupons, in addition to the error of topic, there is also this error under the "Edit Coupon" heading/section of the page:
>The required resource_uri is missing. Please click back and try again.
Sorry again for the confusion here. We are working to improve things.
Is your OAuth client named 'CouponExportAttempt'? I see it attached to a store via a store_full_access scope token. When you copied the client_id and client_secret to the playground code, did you also paste in the refresh token you got from creating the OAuth client? If so, that token would only have the client_full_access scope. You'll need the refresh token with the store_full_access scope or go through the process again with the Example code here: https://github.com/FoxyCart/foxyclient-php-example
The playground code assumes you have an refresh token that already has the store_full_access scope (which you can get from the example code). Yes... it's confusing. The idea was to have the FoxyClient, the example code of how to use it on a very basic level in the Example code (create an OAuth client, create or connect to a user, and create or connect to a store), and then have the playground code for more stuff we'll add later. We'll work to organize this together better, but if you don't have a refresh token with the correct store scope, you'll have to pull up the example code and click the "OAuth Authorization Code grant" link to connect it to your store and then do a view source at the bottom of the page to get your refresh token for your store.
The trick there will be the redirect_url currently configured on your OAuth client (which can be modified if you have the OAuth token with the client_full_access scope). As it's configured now, it will probably redirect to the FoxyTools link.
I hope that helps. If not, it might be best just to start from scratch. I did this last night and it took about 10 minutes total:
1) Using the example code running in a localhost, create an OAuth Client being sure to do so in production (save the client_id, client_secret, and the refresh token at this point which has the client_full_access scope for modifying your client later)
2) Authenticate the OAuth client with your store using the "OAuth Authorization Code grant" link
3) Save the client_id, client_secret, and refresh_token (have to view source to get those values) which at this point has the store_full_access scope.
4) Clone the playground, edit bootstrap to go to production and put in the client_id, client_secret, and refresh_token (need to uncomment that line as well).
5) Restart your localhost server in the playground folder and load up the coupons.
Got most of the way through step 2 before encountering an error.
| Error: This client is invalid or must authenticate using a client secret
After entering my credentials, it asked me to approve/deny.
After approving, it returns that error.
Suggestion ???
Just to confirm - if you're using either of our helper scripts - have you updated it to point to production by setting the sandbox setting to false in bootstrap.php?
Well, more specifically, I commented out `use_sandbox` rather than setting it to false.
Nonetheless, when I run it, it does say "Production" in the top right corner.
Still having the issue.
Thanks SOO much for the patience and hand-holding!
Because of how the credentials are included in the pages after authenticating the client, I @$$umed that was sufficient :P
As soon as I transferred them to the bootstrap file as instructed, everything started falling into place.
Again, thanks-a-bunch
Awesome! I'm glad you were able to get it working! I'm sorry it was such a confusing process. We're working to make the example code simpler moving forward.
I'm experiencing the same problem. But, unlike mOrloff, I've not succeeded in creating a store.
Here's what I've done:
1. Cloned, installed and launched https://github.com/FoxyCart/foxyclient-php-example.
2. Registered my application by creating an OAUTH client
3. Created Foxy user
4. Stored generated client_id, client_secret, refresh_token, access_token and access_token_expires in bootstrap.php
5. Restarted my browser
6. Successfully tested authentication under "Authenticate client" link
7. Attempted to create a Store with my data
It resulted in: Debug output: I am in SANDBOX mode.
Any idea?
Thanks!
Sorry for the confusion! It sounds like perhaps your credentials are only the client scope and not the user scope. A
user_full_access
is need to be able to create a new store for that user.After creating the user you will need to authorize the client to connect to the user, after which point you'll have a user scope, and you can then create stores as that user.It looks like our sandbox admin is down though - so you won't be able to complete that step. I'll connect with our API developer and see about getting that fixed up.
Please let me know if it gets fixed.
We do have some changes that are pending to fix the sandbox there, but unfortunately no ETA on when it will be applied. In the meantime, you could switch to production servers and work through it that way.