admin管理员组

文章数量:1377521

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)

本文标签: pythonNetSuite REST ServicesCannot validate authorizationStack Overflow