Does the user have to be logged in to view products


#1

Hi.

Am I understanding this incorrectly?
When I make an api request to getAllProducts() it has have a authentication in the header.

But when a new client lands on my website, surely its not expected from them to log in first before they can view the products?

Is there a way to show all products without having to be authorized?


#2

Hey @handre

You don’t need to log in the user to view products. The authentication call basically authenticates your app, and gives you back a token to use in subsequent calls to the API. Each token lasts for an hour and if you use something like our Javascript SDK it will handle refreshing the token for you.

Hope this helps

Drew


#3

Hi Drew.

So I must use the sdk? I can’t just use the api?


#4

Hey @handre you don’t have to use the SDK, but it makes it a lot easier to handle authentication.

If you don’t want to use the SDK you will need to handle the authentication in your code. You could have a look at the source code of our SDK to see how this handled and implement it in your own solution.

Thanks


#5

Thanks, I will look into the SDK.

I tested the api call without logging in the user, but I get a 401 (Unauthorized) error.


#6

Hi @handre

I’ve created a quick diagram, hopefully this will be helpful in explaining the authentication process for you.

Thanks,
Adam


#7

Hi @drew @ajsturrock

When I do authentication with postman, I get the access_token but only when I use form data.
As soon as I use json I get a bad request (400).

In my code I am trying to authenticate using json, and once again I am also getting (400) error.
Is there support for authentication via json or only form data?


#8

Hey @handre

At the moment our authentication endpoint accepts x-www-forms-url-encoded. This is a deviation from the norm as the rest of the API accepts JSON apart from Files which accepts multipart/form-data.


#9

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.


#10