-
Notifications
You must be signed in to change notification settings - Fork 55
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't Login with Rest API #27
Comments
Hi @zerodarkzone, This error is because your user doesn't have the right permissions for the REST API. Please consult the NetSuite Help Center. They have good resources on setting up features, roles and permissions correctly for the REST API. |
Hi, as I said, I can use the rest API with Postman with the same credentials. ¿Does this library needs Oauth 2.0 to work?, My user is an administrator and have the right permissions. |
The library only supports OAuth 1 (what NetSuite calls TBA or Token Based Auth) |
Try upgrading to 0.7 that was released today and see if that helps. |
Hi, I thing the problem is the signature method. The library is using "HMAC-SHA1" and it appears it only works with "HMAC-SHA256" Changing the _make_auth method to the following fixed the problem: def _make_auth(self):
from authlib.oauth1.rfc5849.client_auth import ClientAuth
from authlib.oauth1.rfc5849.signature import generate_signature_base_string
from oauthlib.oauth1.rfc5849.signature import sign_hmac_sha256
def sign_hmac_sha256_with_client(client, request):
"""Sign a HMAC-SHA1 signature."""
base_string = generate_signature_base_string(request)
return sign_hmac_sha256(
base_string, client.client_secret, client.token_secret)
ClientAuth.register_signature_method("HMAC-SHA256", sign_hmac_sha256_with_client)
auth = self._config.auth
return OAuth1Auth(
client_id=auth.consumer_key,
client_secret=auth.consumer_secret,
token=auth.token_id,
token_secret=auth.token_secret,
realm=self._config.account,
force_include_body=True,
signature_method="HMAC-SHA256",
) It would be great if you could add the signature_method as a parameter and implement the hmac_sha56 in a clean way. |
HMAC-SHA1 works for me on 2021.1. Have you disabled it somehow or are you on 2021.2 beta? |
Thanks for the code for HMAC-SHA256. I’ll see about adding it later. |
Ah! I think I found the reason for why it's working for me but not for you: https://docs.oracle.com/cloud/latest/netsuitecs_gs/NSATH/NSATH.pdf
So I'll look into moving to HMAC-SHA256 as the default. |
@zerodarkzone This has now been fixed. HMAC-SHA256 is now the default signing method for REST API and Restlet. |
Release 0.8.0 was just released with this fix. |
Hi, thanks for the fix. |
Hi I'm trying to use the rest_api provided in this library, but I can't get the login to work.
Right now, the SOAP api works fine and I can use the REST API through Postman without problems.
If I try the following code, everything works.
However, if I do the following:
I get the following error:
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: