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

Error occuring on authentication of non embeded app #375

Open
julesbl opened this issue Oct 10, 2024 · 4 comments
Open

Error occuring on authentication of non embeded app #375

julesbl opened this issue Oct 10, 2024 · 4 comments

Comments

@julesbl
Copy link

julesbl commented Oct 10, 2024

When using the package for OAuth of an offline/not embedded app, the function OAUTH::callback() attempts to use setcookie() with a null value for expires: parameter.

The same issue was raised here
#291
This issue is still extant as the pull request failed, I made the changes indicated and it works, however if I update my version I will be back to a fail again.

@matteodepalo
Copy link
Contributor

Hi @julesbl, just to clarify, you made the changes in this PR and it worked?

@julesbl
Copy link
Author

julesbl commented Oct 29, 2024 via email

@sammyteahan
Copy link

I just wanted to jump in and mention I'm facing the same error and applying the fix in PR #293 resolves the issue for me.

@sammyteahan
Copy link

For posterity, you can side-step this issue for now by providing your own function to setCookieFunction when using OAuth::begin and OAuth::callback. Ensure you handle setting the expiration value of the cookie with the value you expect, or 0 (instead of null).

Example

function buildAppAuthUrl(string $storeDomain)
{
    $shopifyOAuthCookie = new ShopifyOAuthCookie();
    $cookieFunction = [$shopifyOAuthCookie, 'set'];

    return OAuth::begin(
        isOnline: false,
        shop: $shopDomain,
        redirectPath: '/shopify/auth/callback',
        setCookieFunction: $cookieFunction,
    );
}

class ShopifyOAuthCookie
{
    public static function set(OAuthCookie $cookie): bool
    {
        return setcookie(
            $cookie->getName(),
            $cookie->getValue(),
            $cookie->getExpire() ?? 0,
            "",
            "",
            $cookie->isSecure(),
            $cookie->isHttpOnly(),
        );
    }
}

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