Last active
March 13, 2018 14:51
-
-
Save phaelfp/a79ba10fd021b06b53202cfe2deac7c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using Component Grovy | |
import org.scribe.builder.ServiceBuilder; | |
import org.scribe.model.*; | |
import org.scribe.oauth.OAuthService; | |
import java.util.Scanner; | |
import org.scribe.oauth.*; | |
OAuthService service = new ServiceBuilder() | |
.provider(classProvider) | |
.apiKey("API-KEY") | |
.apiSecret("API-SECRET") | |
.debug() | |
.build(); | |
Token permanentToken = new Token("permanent-key", "permanent-secret"); | |
OAuthRequest request = new OAuthRequest(Verb.POST, "URL_API_REST"); | |
request.addHeader("Content-Type", "application/json"); | |
request.addHeader("Accept", "application/json"); | |
request.addPayload(flowVars.content_product); | |
service.signRequest(permanentToken, request); | |
Response response = request.send(); | |
System.out.println(response.getCode()); | |
System.out.println(response.getBody()); | |
flowVars['error_description'] = response.getBody() | |
flowVars['mage_code_response'] = response.getCode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment