最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - NetSuite REST Services - Cannot validate authorization - Stack Overflow

programmeradmin2浏览0评论

I'm trying to call this API and am constantly getting a 401 error. Not sure what more I need to do to get it working. I've tried running with just HASH, and with a multitude of different libraries, but can't get the authorization to kick over. Really any help pointing out my error would be greatly appreciated.

import datetime
import random
import pandas as pd
from requests_oauthlib import OAuth1


CONSUMER_KEY = "123456789123" 
CONSUMER_SECRET = "12345678901234" 
ACCESS_TOKEN = "1234567890123456789" 
TOKEN_SECRET = "1234567890123456789" 
ACCOUNT_ID = "1234567"
API_URL = ";
HTTP_METHOD = "GET"


timestamp = str(int(datetime.datetime.utcnow().timestamp()))
nonce = ''.join(random.choices('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=11)) 


auth = OAuth1(
    CONSUMER_KEY,
    client_secret=CONSUMER_SECRET,
    resource_owner_key=ACCESS_TOKEN,
    resource_owner_secret=TOKEN_SECRET,
    signature_method="HMAC-SHA256",
    signature_type="auth_header"
)


headers = {
    "Content-Type": "application/json",
    "Accept": "application/json"
}

response = requests.get(API_URL, auth=auth, headers=headers)


print(f"{response.status_code}")


if response.status_code == 200:
    data = response.json()
    df = pd.DataFrame(data.get("items", []))  
    print(df)
else:
    print(response.text)

发布评论

评论列表(0)

  1. 暂无评论