Trouble authenticating a request from a POS UI extension

Solved

Trouble authenticating a request from a POS UI extension

alexis2m
Shopify Partner
8 1 0

Hi,

 

I've been trying to authenticate a request from a POS UI extension to my Remix app.

 

I want to use: 

const { admin } = await authenticate.public.appProxy(request);
 or:
const { admin } = await authenticate.admin(request);
In my POS UI extension, I'm able to get the session token:
const [sessionToken, setSessionToken] = useState<string | null | undefined>(
    null,
  );

  useEffect(() => {
    getSessionToken().then((token) => {
      setSessionToken(token);
    });
  }, [shopDomain, getSessionToken]);
But I cannot find any details about authenticating the request.
If I'm using it as a Bearer token, I get:
shopify-app/INFO] Query does not contain a signature value
And if I don't use any, I get an empty error.
 
What do I do wrong ?
Designer & Developer. Food lover. Human being.
Accepted Solution (1)

alexis2m
Shopify Partner
8 1 0

This is an accepted solution.

Actually, here was the solution:

 

Use the session_token and pass it as a Bearer in the fetch request.

 

On remix, use:

 

const session = await authenticate.admin(request);

 

 

But, in case of any error, I use:

 

 

const decoded = jwt.verify(token, process.env.SHOPIFY_API_SECRET!, {
algorithms: ["HS256"],
});

 

Designer & Developer. Food lover. Human being.

View solution in original post

Reply 1 (1)

alexis2m
Shopify Partner
8 1 0

This is an accepted solution.

Actually, here was the solution:

 

Use the session_token and pass it as a Bearer in the fetch request.

 

On remix, use:

 

const session = await authenticate.admin(request);

 

 

But, in case of any error, I use:

 

 

const decoded = jwt.verify(token, process.env.SHOPIFY_API_SECRET!, {
algorithms: ["HS256"],
});

 

Designer & Developer. Food lover. Human being.