Unable to obtain fx:store href

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.
Comments
  • fc_adamfc_adam FoxyCart Team
    @mOrloff,

    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!
  • fc_adamfc_adam FoxyCart Team
    @mOrloff,

    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 in bootstrap.php is set to false.

    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 and refresh_token (you'll need to check the page source to get the last two). Paste those three values into the FoxyClient Playground script's bootstrap.php file, and again - ensure that use_sandbox is set to false.

    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.
  • 1. I created OAuth token via https://foxytools.com/app/custom/api-client-builder/
    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.
  • lukeluke FoxyCart Team
    Hey @mOrloff

    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.
  • Great instructions.
    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 ???
  • fc_adamfc_adam FoxyCart Team
    @mOrloff,

    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?
  • Yes.
    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.
  • lukeluke FoxyCart Team
    In the bootstrap file, did you include your client_id and client_secret you got form step 1? If it says you need a secret, then something's not right there. Also, depending on how you configured the redirect_url when you created the client, are you sure you're going to the right place when it redirects back after the OAuth interaction?
  • mOrloffmOrloff Member
    edited March 2016
    TADA!!!!!

    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
  • fc_adamfc_adam FoxyCart Team
    @mOrloff,

    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.
  • @fc_adam, @luke

    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:

    Error:
    Unable to obtain fx:stores href
    Debug output:

    * Rebuilt URL to: https://api-sandbox.foxycart.com/
    * Hostname was found in DNS cache
    * Hostname in DNS cache was stale, zapped
    * Trying 107.21.62.108...
    * Connected to api-sandbox.foxycart.com (107.21.62.108) port 443 (#6)
    * successfully set certificate verify locations:
    * CAfile: /etc/cacert.pem
    CApath: /etc/ssl/certs
    * SSL connection using ECDHE-RSA-AES128-GCM-SHA256
    * Server certificate:
    * subject: C=US; ST=Tennessee; L=Brentwood; O=FoxyCart.com LLC; CN=*.foxycart.com
    * start date: 2013-10-22 12:00:01 GMT
    * expire date: 2016-09-28 12:00:00 GMT
    * subjectAltName: api-sandbox.foxycart.com matched
    * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
    * SSL certificate verify ok.
    > GET / HTTP/1.1
    Host: api-sandbox.foxycart.com
    FOXY-API-VERSION: 1
    Authorization: Bearer 0bae4f34fc29ab2e5bb964d5a6e52d6140f37395
    Accept: application/hal+json
    User-Agent: Guzzle/5.3.0 curl/7.35.0 PHP/5.6.11
    I am in SANDBOX mode.

    Any idea?

    Thanks!
  • fc_adamfc_adam FoxyCart Team
    @temuri416,

    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.
  • Thanks,

    Please let me know if it gets fixed.
  • fc_adamfc_adam FoxyCart Team
    @temuri416,

    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.
Sign In or Register to comment.