CRISP Commercetools

65 views
Skip to first unread message

Michel.Drenthe

unread,
Oct 24, 2017, 11:31:20 AM10/24/17
to Hippo Community
I try to connect CRISP with commercetools.
For there OAuth2 endpoint the need it to be a POST (Default is GET)

Can someone provide me with a example how to connect: [1]

Woonsan Ko

unread,
Oct 24, 2017, 11:36:20 AM10/24/17
to hippo-c...@googlegroups.com
Hi Michel,

I will document it online soon, but let me write here how to achieve that.
By default, resource resolving and finding resources are using GET method, but you can change it to POST and even pass http header and/or body like the following example:

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;

ResourceServiceBroker resourceServiceBroker = CrispHstServices.getDefaultResourceServiceBroker();

// See the javadoc of Spring Framework's HttpEntity class for details.
HttpHeaders headers = new HttpHeaders();
// adding an http header for instance
headers.setContentType(MediaType.APPLICATION_JSON_VALUE);
// you can also add http request body as well...
String body = "{ \"filterFieldName\": ... }";
HttpEntity requestEntity = new HttpEntity(body, headers);

// the latest version of CRISP supports ExchangeHint argument for this use case.
Resource products = resourceServiceBroker.findResources("commercetools", "/products/",
        ExchangeHintBuilder.create().methodName("POST").request(requestEntity).build());


HTH,

Woonsan


DISCLAIMER:
The information contained in this message may be confidential or privileged and is only intended for the use of the addressee. If you are not the intended recipient, you are requested by Qualogy to report this to the sender and to delete the message and you are notified that the use or distribution of the information contained in this message is strictly prohibited and unlawful.

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--
71 Summer Street, 2nd Floor, Boston, MA 02110
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

Michel.Drenthe

unread,
Oct 24, 2017, 11:51:37 AM10/24/17
to Hippo Community
It's only for the OAuth2 part.

Op dinsdag 24 oktober 2017 17:36:20 UTC+2 schreef woonsan.ko:
To post to this group, send email to hippo-c...@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.

Woonsan Ko

unread,
Oct 24, 2017, 12:08:22 PM10/24/17
to hippo-c...@googlegroups.com
Could you try my example? I think Spring RestTemplate uses the same HTTP method name given on #execute...(...) method (for resources) for the authentication, actually using the same request object.

Regards,

Woonsan


To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

mix...@gmail.com

unread,
Oct 24, 2017, 3:32:56 PM10/24/17
to Hippo Community
Not working:
Logging: [DefaultPageErrorHandler.logWarningsForEachComponentExceptions:51] Component exception on com.wijnplaza.components.ProductsComponent : org.onehippo.cms7.crisp.api.resource.ResourceException: Unknown error.

Woonsan Ko

unread,
Oct 24, 2017, 3:36:09 PM10/24/17
to hippo-c...@googlegroups.com
If you add the following in your logging configuration, you can look into all the http payloads between your application and commercetools:

<Logger name="org.apache.http" level="debug" />
<Logger name="org.apache.http.wire" level="debug" />
<Logger name="org.onehippo.cms7.crisp" level="debug" />

So, I guess you can see if it's sending request with POST method and proper values from the logs.

Regards,

Woonsan



On Tue, Oct 24, 2017 at 3:30 PM, <mix...@gmail.com> wrote:
Not working:
Logging: [DefaultPageErrorHandler.logWarningsForEachComponentExceptions:51] Component exception on com.wijnplaza.components.ProductsComponent : org.onehippo.cms7.crisp.api.resource.ResourceException: Unknown error.

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.
71 Summer Street, 2nd Floor, Boston, MA 02110
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466



MiXeD

unread,
Oct 25, 2017, 11:36:29 AM10/25/17
to Hippo Community
Ok, it logs in, only the command it executes towards the api is now in post as well.
Where it need to be a GET. do I need to run the command twice where i expect the first one to throw an error?

Op dinsdag 24 oktober 2017 21:36:09 UTC+2 schreef woonsan.ko:
If you add the following in your logging configuration, you can look into all the http payloads between your application and commercetools:

<Logger name="org.apache.http" level="debug" />
<Logger name="org.apache.http.wire" level="debug" />
<Logger name="org.onehippo.cms7.crisp" level="debug" />

So, I guess you can see if it's sending request with POST method and proper values from the logs.

Regards,

Woonsan


On Tue, Oct 24, 2017 at 3:30 PM, <mix...@gmail.com> wrote:
Not working:
Logging: [DefaultPageErrorHandler.logWarningsForEachComponentExceptions:51] Component exception on com.wijnplaza.components.ProductsComponent : org.onehippo.cms7.crisp.api.resource.ResourceException: Unknown error.

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.

Woonsan Ko

unread,
Oct 25, 2017, 12:06:02 PM10/25/17
to hippo-c...@googlegroups.com
On Wed, Oct 25, 2017 at 11:36 AM, MiXeD <mix...@gmail.com> wrote:
Ok, it logs in, only the command it executes towards the api is now in post as well.
Where it need to be a GET.
Do you mean there's an API endpoint in commercetools, requiring GET method, but the authentication itself requiring POST method?
Hmm... if it's the case, that's a bit weird. You can ask commercetools guys about why they don't provide an equivalent POST-based APIs if they force you to use POST for OAuth2 authentication (via headers).

do I need to run the command twice where i expect the first one to throw an error?
If commercetools REST API is designed in that way, I guess you should do that. It's not really a problem of CRISP API.

Regards,

Woonsan
 
To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

MiXeD

unread,
Oct 25, 2017, 12:13:35 PM10/25/17
to Hippo Community
For the authentication part they are calling it OAth2 i need to do a POST to endpoint: https://auth.sphere.io/oauth/token
In the response i get the bearer token back.

That can be used to make any GET,POST,DELETE
That's available on: https://api.sphere.io/{store}/{EndPoint}

Op woensdag 25 oktober 2017 18:06:02 UTC+2 schreef woonsan.ko:
Reply all
Reply to author
Forward
0 new messages