Jump to content

Richard Hallgren

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Richard Hallgren

  1. I have tried to obtain a new access and refresh token with Python but I cant get it to work:

    import http.client

    connection = http.client.HTTPSConnection('oauth.accounting.sage.com', 443, timeout = 30)
    headers = {"client_id":client_id_sage_value,
            "Content-Type":"application/x-www-form-urlencoded",
            "client_secret":client_secret_sage_value,
            "grant_type": "refresh_token",
            "refresh_token":refresh_token_value,
            "Accept":"application/json"}

    # Send synchronously

    connection.request('POST', '/token', None, headers)
    try:
        response = connection.getresponse()
        content = response.read()
        # Success
        print('Response status ' + str(response.status))
    except http.client.HTTPException as e:
        # Exception
        print('Exception during request')

     

    I get a Response status 400 with the following content:

    "

    b'{"$severity":"error","$dataCode":"DataParsingError","$message":"The data you sent could not be processed.","$source":"Proxy"}'

     

    Does anyone have any tips on how to obtain the refresh token with Python? It works in Postman with the user interface, also I can make GET requests with the some minor modifications to the code to obtain account information etc.

×
×
  • Create New...