cancel
Showing results for 
Search instead for 
Did you mean: 

Access products from a ywebservices extension - OAuth2

202

I have created an extension based on "ywebservices" (called "exchange") that exposes some endpoints to maintain data like Products.

I have created client credentials which I am using to retrieve a token which then I am including in my requests to access the ./exchange' endpoints. I am being able also to hit the controller's methods down to their custom facades.

The problem is that when I try to find a product from a given catalog version I get the following error:

ERROR [hybrisHTTP12] [RestHandlerExceptionResolver] de.hybris.platform.servicelayer.search.exceptions.FlexibleSearchException: could not translate value expression 'session.catalogversions'
    at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService$3.execute(DefaultFlexibleSearchService.java:542)
    at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService$3.execute(DefaultFlexibleSearchService.java:1)
    at de.hybris.platform.servicelayer.session.impl.DefaultSessionService.executeInLocalView(DefaultSessionService.java:89)
    at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.getJaloResult(DefaultFlexibleSearchService.java:511)
    at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.search(DefaultFlexibleSearchService.java:184)
    at de.hybris.platform.servicelayer.internal.dao.DefaultGenericDao.find(DefaultGenericDao.java:51)
    at de.hybris.platform.product.daos.impl.DefaultProductDao.findProductsByCode(DefaultProductDao.java:125)
    at de.hybris.platform.product.impl.DefaultProductService.getProductForCode(DefaultProductService.java:214)
    at com.acme.exchange.facade.impl.DefaultExchangeProductFacade.isExistingProduct(DefaultExchangeProductFacade.java:229)
    at com.acme.exchange.facade.impl.DefaultExchangeProductFacade.createProduct(DefaultExchangeProductFacade.java:79)
    at com.acme.exchange.controller.ProductExchangeController.createProduct(ProductExchangeController.java:85)

I notice that I am successfully being authenticated, however my session is being assigned to user "anonymous".
I have tried calling this before running the query, but I still get the same error:

catalogVersionService.setSessionCatalogVersion(CATALOG_ID, CATALOG_VERSION);

This is how I created the client credentials:

INSERT_UPDATE OAuthClientDetails;clientId[unique=true]; resourceIds; scope[mode=append] ; authorizedGrantTypes; authorities                    ; clientSecret; registeredRedirectUri
                                ;exchange_client      ; hybris     ; basic              ; client_credentials  ; ROLE_CLIENT,ROLE_TRUSTED_CLIENT; secret      ;

What do I need to do in order to be able to access products?

Accepted Solutions (0)

Answers (0)