Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get store access token with the library #289

Closed
netsystek opened this issue Jul 19, 2023 · 5 comments
Closed

Unable to get store access token with the library #289

netsystek opened this issue Jul 19, 2023 · 5 comments

Comments

@netsystek
Copy link

netsystek commented Jul 19, 2023

I'm using Shopify/shopify-api-php library to try to connect to an online store but when i'm using provided methods Context::initialize() like docs on and nothing happens.

I would like to be able to get the online store access token

Nothing happens and not file provided in path SHOPIFY_SESSION_STORAGE_PATH in my custom path /tmp/shopify_session

Steps to reproduce the problem

  1. initialize context with Context::initialize() method

There is the following used code:

        Context::initialize(
            apiKey: $_ENV['SHOPIFY_API_KEY'],
            apiSecretKey: $_ENV['SHOPIFY_API_SECRET'],
            scopes: $_ENV['SHOPIFY_APP_SCOPES'],
            hostName: $_ENV['SHOPIFY_APP_HOST_NAME'],
            sessionStorage: new FileSessionStorage(),
            apiVersion: $_ENV['SHOPIFY_API_VERSION'],
            isEmbeddedApp: $_ENV['SHOPIFY_EMBEDDED_APP'],
            isPrivateApp: $_ENV['SHOPIFY_PRIVATE_APP'],
        );

I'm using Symfony framework and the php8.1 version on docker stack

Thank you for help

@netsystek
Copy link
Author

Other thing i builded a services who's implement the SessionStorage to try to get the context into symfony session
but the service is never called.
The is the following code:

Into the service

...
use Shopify\Auth\SessionStorage;
class ShopifySessionStorage implements SessionStorage
{
    private BaseSession $symfonySession;
    public function storeSession(Session $session): bool
    {
        $this->symfonySession = new BaseSession();
        $this->symfonySession->set('shopify_session', $session);

        if ($this->symfonySession->get('shopify_session')) {
            return true;
        }
        return false;
    }
...
...

Into the controller

...
        Context::initialize(
            apiKey: $_ENV['SHOPIFY_API_KEY'],
            apiSecretKey: $_ENV['SHOPIFY_API_SECRET'],
            scopes: $_ENV['SHOPIFY_APP_SCOPES'],
            hostName: $_ENV['SHOPIFY_APP_HOST_NAME'],
            sessionStorage: new ShopifySessionStorage(),
            apiVersion: $_ENV['SHOPIFY_API_VERSION'],
            isEmbeddedApp: $_ENV['SHOPIFY_EMBEDDED_APP'],
            isPrivateApp: $_ENV['SHOPIFY_PRIVATE_APP'],
        );
...

Thank you for your helping

@elburro1887
Copy link

Since the great devs here at Shopify don't seem to give a damn about their API users, you should check the old Github issues, where people like us are helping each other out.
For example: #151

@netsystek
Copy link
Author

Hello @elburro1887 thank you for your answer i already came across this topic it helped me to see more clearly. So my problem is i don't have an access token so i can't do anything. do you have any idea how i can get it using SHOPIFY_API_KEY and SHOPIFY_API_SECRET ? Thank you

@FutureFutureTo
Copy link

^ this is where im at as well....im stuck at even getting an access token

@elburro1887
Copy link

To get these tokens, first you have to create a shopify app (public or private) and then you will get the respective ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants