× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



It actually looks more like request for an OAuth 2.0 Token. (ie, first
you get a code, then exchange for a token and refresh token which are used
from there on out).

OAuth 2.0 is getting very popular, and if you don't understand the process,
it can be quite confusing. What's worse, I've seen OAuth that is JSON and
then all APIs (which use the OAuth token in the requests) are only XML.
Talk about yuk.

Anyhow, it looks like now with these examples the OP is trying to do OAuth
2.0 and get that going. If so, there's a lot more to it that making a
couple requests. It normally requires callbacks to HTTPS servers as well.

I've set this sort of thing up for MS, Google, Slack, HubSpot, PayPal, Ebay
(which was the worst!) and a few other platforms for customers. Happy to
help if the OP doesn't want to learn the hard way. Just contact me
offline.

I've never seen 2 OAuth 2.0 systems the same, but they are normally close.
For example this one seems to require a password instead of an
authentication code. So we're still only seeing a very small part of the
big picture the OP is trying to do.

Bradley V. Stone
www.bvstools.com
MAILTOOL Benefit #7 <https://www.bvstools.com/mailtool.html>: The ability
to completely bypass the IBM SMTP system all together using MAILTOOL Plus
or other Addons.

On Thu, Apr 4, 2019 at 3:30 PM Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
wrote:

Ron,

I'm not familiar with these Java classes. (This is definitely not
JavaScript, it is Java.)

If I had to guess, I'd say this is simply creating a web form (not a
JSON document.) Can you explain why you used a JSON document in your
earlier RPG example?

-SK


On 4/4/19 1:22 PM, Hudson, Ron wrote:
Hi Scott,

After getting in touch with the Vertex Cloud technical team, they
provided the following explanation and Javascript solution. Does your tool
have a solution for this?

The Authentication server is not going to be compatible with the RAW
JSON at this moment because this is throwing a security flag from our auth
server. The authentication process that will have to be implemented into
your client in order to get the accessToken should look something like the
following Javascript:

public OAuthResponse getAccessToken() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String,String> map = new LinkedMultiValueMap<>();
map.add("client_id", "1c2fxxxx-xxxx-xxxx-xxxx-xxxx9a5b2474");
map.add("client_secret",
"e645xxxx-xxxx-xxxx-xxxx-xxxxaf9a317c");
map.add("grant_type", "password");
map.add("username", "c7ddxxxx-xxxx-xxxx-xxxx-xxxx6a8a32b1");
map.add("password", "a6adxxxx-xxxx-xxxx-xxxx-xxxx22c0b8d7");
map.add("scope", "calc-rest-api");

HttpEntity<MultiValueMap<String,String>> entity = new
HttpEntity<>(map, headers);
ResponseEntity<OAuthResponse> response;
OAuthResponse oAuthResponse = null;
try {
response = restTemplate.postForEntity(oauthUrl, entity,
OAuthResponse.class);
oAuthResponse = response.getBody();
} catch (HttpClientErrorException e) {
if (e.getStatusCode().value() >= 400) {
return
refreshAccessToken("350630f9-4b6e-47cf-86e3-c1682fcb4ed5");
} else {
String msg = String.format("error while communicating
with auth server: %s", e.getMessage());
throw new GeneralAuthServerException(msg);
}
} catch (Exception e) {
String msg = String.format("error while communicating with
auth server: %s", e.getMessage());
throw new GeneralAuthServerException(msg);
}

if (oAuthResponse == null) {
throw new GeneralAuthServerException("OAuth server returned
invalid response");
} else {
return oAuthResponse;
}
}


Ron Hudson | Programmer / Analyst
+1.704.752.6513 x1324
www.invue.com
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott
Klement
Sent: Wednesday, April 3, 2019 11:45 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: REST request to Vertex Cloud

Ron,

I am not familiar with 'Vertex Cloud' and hadn't heard of it prior to
your post.

The data you're sending is a JSON document, so the correct content-type
would be 'application/json'. You say that gives you a 415 response, which
makes me think I'm missing something in how this is supposed to work.

You say you tried 'x-www-form-urlencoded' but that is not a valid media
type at all. You probably meant 'application/x-www-form-urlencoded',
which is the default media type for HTML form data. (However, your JSON
document is not HTML form data, at least not the way you've coded it.)

If you can tell me how you're supposed to send it, I could tell you how
to do it in HTTPAPI. But, I can't figure it out from the info you've
supplied.

-SK


On 4/3/19 10:28 AM, Hudson, Ron wrote:

Has anyone had success using a REST request to the Vertex Cloud for
sales tax calculations? If so, any advice? Vertex has been of little
help, all their IBM i connections are SOAP.

I'm attempting to use Scott's HTTPAPI version 1.39, O/S version V7R3M0.

The debug log shows I am making the connection, but I am receiving
either 400 Bad Request or 415 Unsupported Media Type , depending on what
"Content-Type" is sent.
Testing the connection with Postman is successful.

Entire test program below:

http_debug(*on: '/tmp/debug.txt');

JSONsecurity = '+
{"client_id":"Rest-API-xxxxxxxxxxxxxxxxx",+
"client_secret":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",+
"username":"xxxxxxxxxxxxxx",+
"password":"xxxxxxxxxx",+
"scope":"calc-rest-api",+
"grant_type":"password"}';

URL = 'https://auth.vertexsmb.com/identity/connect/token';

monitor;
resp= http_string('POST': url : JSONsecurity :
'x-www-form-urlencoded'); on-error;
httpcode = http_error();
endmon;
*inlr = *on;


Results from different "Content-Type" below
// 'x-www-form-urlencoded' 400 Bad Request
(this was successful in Postman)
// 'application/json' 415 Unsupported Media Type
// 'accept: text/json' 400 Bad Request
// 'text/json' 415 Unsupported Media
Type
// 'text/plain' 415 Unsupported Media
Type
// 'accept: text/plain' 400 Bad Request

Thanks
Ron
--
Scott Klement
http://www.scottklement.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
Scott Klement
http://www.scottklement.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.