2

I am getting below exception while accessing customer shop OCAPI to register customer or get customer profile. I have provided Oauth token for default client id as : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Request: POST https://hostname:port/dw/shop/v19_8/customers

https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FOCAPI%2Fcurrent%2Fshop%2FResources%2FCustomers.html&cp=0_12_3_5

Exception: "type": "AccessWithoutUserForbiddenException", "message": "An authenticated user is required in order to access the resource."

Could you help me with this? Any Idea or suggestion would be appreciated.

1
  • Post the entire request/response with any sensitive info redacted as shown in the Samples section of the doc
    – identigral
    Aug 21, 2019 at 19:14

2 Answers 2

2

You can access OCAPI Shop API resources within valid customer session OR by using Business Manager credentials. In your case you retrieved access token by using client id and client password. In order to access shop resources outside customer session you have to authenticate your request with BM username, BM password and client password.

Check this page for more details: https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/OCAPI/current/usage/OAuth.html?cp=0_12_2_22

Example collection: https://github.com/velizarn/postman-ocapi-collections

0

Too late to the game but hope this helps someone. To register as a new customer using the Customers resource of the shop API , you need to use a JWT which has been created using {type:"guest"} when hitting the customers/auth API.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .