aspose-pdf-cloud / aspose-pdf-cloud-python

Python library for communicating with the Aspose.PDF Cloud API
MIT License
11 stars 5 forks source link

Trouble following instructions to connect to API #35

Open audrow opened 3 years ago

audrow commented 3 years ago

The README says that I can create an API client in the following way:

  # Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required).

  pdf_api = asposepdfcloud.PdfApi('MY_CLIENT_ID', 'MY_CLIENT_SECRET')

  file_name = 'PdfWithAnnotations.pdf'
  page_number = 2
  response = pdf_api.get_page_annotations(file_name, page_number, folder=temp_folder)

but the PdfApi has the following init:

class PdfApi(object):
    def __init__(self, api_client=None):
        ...

I tried passing in the ApiClient then, but the ApiClient takes an app_key and app_sid, which I haven't been able to find on the Aspose website after registering and creating an application. I tried using my client ID and client secret for these arguments, respectively, but I get an invalid client error, so I suspect that I didn't create the client correctly.

asposepdfcloud.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Sat, 20 Mar 2021 22:05:00 GMT', 'Content-Type': 'application/json; charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Set-Cookie': 'AWSALB=GEPeXFXylmkX26v1qIjS7hP9twmsQm6aYh0INhQ4x8rCSmtPTfdUILgfMq+QPyqQlXgznQ9VvLp1f/LcBCUlXncp1UYUY8G/C4uXNCjCnFlgmKh3mcbz4QvrSTJI; Expires=Sat, 27 Mar 2021 22:05:00 GMT; Path=/, AWSALBCORS=GEPeXFXylmkX26v1qIjS7hP9twmsQm6aYh0INhQ4x8rCSmtPTfdUILgfMq+QPyqQlXgznQ9VvLp1f/LcBCUlXncp1UYUY8G/C4uXNCjCnFlgmKh3mcbz4QvrSTJI; Expires=Sat, 27 Mar 2021 22:05:00 GMT; Path=/; SameSite=None; Secure, .Prj.Customer=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax, .Prj.Customer=1c681fac-b5ae-4078-bede-29c25d3578dc; expires=Sun, 20 Mar 2022 22:05:00 GMT; path=/; samesite=lax; httponly', 'Cache-Control': 'no-store, no-cache, max-age=0', 'Pragma': 'no-cache'})
HTTP response body: {"error":"invalid_client"}

Any suggestions on how to proceed?

dishwad commented 9 months ago

If you look into ApiClient and how it makes requests you'll see that app_key is the client secret and app_sid is the client ID. This is really confusing and should be fixed.