Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added HMAC-SHA256 Signature Service and NetSuite API#1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
svonduhn wants to merge8 commits intoscribejava:master
base:master
Choose a base branch
Loading
fromsvonduhn:NetSuiteHMAC-SHA256

Conversation

svonduhn
Copy link

Added HMAC-SHA256 signature service, which is now required by NetSuite. Also added NetSuite API as a convenience, to ensure that the correct signature service is used, along with NetSuite example code.

ma-chisuke, EddyVerbruggen, qpratttech, and rhajek reacted with thumbs up emoji
@zarkone
Copy link

@svonduhn thanks for this PR!

GET from works good for me, but I didn't manage to get POST request to work. For example,/record/v1/customer with body parameters. I see "invalid signature" in Audit, but have no idea what exactly went wrong in a signature process

Is there any change you have an example on how to compose a POST request with body parameters?

Thanks!

@svonduhn
Copy link
Author

@zarkone Our account does not have the REST web services feature enabled, so I can only test with Restlets. However, I was able to make POST and PUT calls to a RESTlet just fine, using a JSON payload (request body), by calling setPayload with a request body.

    final OAuthRequest request = new OAuthRequest(Verb.POST, PROTECTED_RESOURCE_URL);    request.setRealm(ACCOUNT_ID);    service.signRequest(accessToken, request);    request.addHeader("Content-Type", "application/json");    request.setPayload("[{\"a\":1},{\"b\":false}]");

The Realm still must be set before signing the request, as it is part of the Authorization header, even though it is not used in the signature itself.

It's possible you may need to set some additional headers when sending a payload body for REST web service that Restlets don't require. Do you have access to any RESTlets to test that?

If not, you can use this Echo RESTlet that will send back any GET, PUT, or POST request with the following code:

/** @NScriptType restlet* @NApiVersion 2.1*/define(() => { let echo = body => body; return { get: echo, put: echo, post: echo } })

Let me know if that works.

@zarkone
Copy link

@svonduhn thanks for your reply!

I get it to work, but the issue was that I've added body parameters to signature. It was a stupid mistake, but for some reason I decided that it is a good idea back then (and forgot about it). "Some reason" could be that because of Netsuite doesn't requirebody_hash to be added to signature, I assumed that I need to add body params...

This also means that the signature would be the same for different body, if I understand everything correct.

@svonduhn
Copy link
Author

@zarkone Apart from the fact that the nonce and timestamp will be different for each call, the other parameters will essentially always be the same for any POST or PUT call, regardless of what is in the body/payload. But the two non-static values will still cause the signature to change each time anyway.

zarkone reacted with thumbs up emoji

@natzei
Copy link

Hello guys, thank you for this contribution! Any update on this Pull Request? I would like to use the new Signature Service as part of my implementation.

@andynormancx
Copy link

As of this week our Netsuite integration no longer works due to not using SHA1, so I guess they've started rolling out SHA256 only.

I guess I'll be forking and building a local copy.

@andynormancx
Copy link

Does anyone have any tips on building it locally, when I try I get this duringmvn compile:

Could not resolve dependencies for project com.github.scribejava:scribejava-core:jar:8.3.2-SNAPSHOT: com.github.scribejava:scribejava-java8:jar:8.3.2-SNAPSHOT was not found in https://oss.sonatype.org/content/repositories/snapshots

@natzei
Copy link

The sandbox environment only supports HMAC-SHA256 starting from the 30th of July.

The end of support for HMACSHA1 in production is expected by the middle of August. It's still not clear to me if they already supports HMAC-SHA256 in production and can (temporarily) use both algo until the dismission of HMAC-SHA1.

@svonduhn
Copy link
Author

@andynormancx trymvn install instead.

Alternatively, you can just use the latest published version of scribejava, 8.3.1, then add copies of the HMACSha256SignatureService and NetSuiteApi classes directly to your project.

andynormancx, natzei, and gavinstansill reacted with thumbs up emoji

@svonduhn
Copy link
Author

@natzei You can definitely use HMAC-SHA256 right now. You do not need to wait for HMAC-SHA1 to be deprecated.

natzei reacted with thumbs up emoji

@gavinstansill
Copy link

Thanks this was a huge help. My SB has required HMAC256, like mentioned earlier, since Jul 30. My production environment has not followed suit yet, but it looks like they roll out thru October.

@boh717
Copy link

boh717 commentedMay 25, 2022
edited
Loading

Hey guys,
any chance to get this merged?

tomaspizarro15, EddyVerbruggen, cbarrerah, and rhajek reacted with thumbs up emoji

@cbarrerah
Copy link

cbarrerah commentedJun 17, 2024
edited
Loading

Hi there,
Any chance of this being merged? Looks like a nice addition, and it would make Scribe a very nice option for all those integration designing companies ;)

BTW I can confirm it works with restlets in the latest NetSuite 24.1 version

@rhajek
Copy link

Works good, tested on Netsuite 2024.2. Nice addition, you should merge it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

9 participants
@svonduhn@zarkone@natzei@andynormancx@gavinstansill@boh717@cbarrerah@rhajek@svonduhn-chub

[8]ページ先頭

©2009-2025 Movatter.jp