Skip to main content
Participant
January 29, 2024
Question

Generating forbidden error 403 invalid client id

  • January 29, 2024
  • 2 replies
  • 1987 views

we have created credentials (server to server authentication) as  per te documentation and generated access token using rest api.

When trying to  generate upload presigned URI using Java https://developer.adobe.com/document-services/apis/pdf-services/  using api key  generated in credentials we are getting forbidden error  http errocode 403 (error code: 403003) Clientid Id is invalid.

2 replies

Raymond Camden
Community Manager
Community Manager
January 29, 2024

Can you show some of your code so I can see how you are making the call? The process should be - exchange client id + secret for an authorization token. That token is then used in your next call.

Participant
January 30, 2024

# Get access token (you may use your own method to obtain the token)
def get_access_token(client_id, client_secret):
    auth_url = 'https://ims-na1.adobelogin.com/ims/token/v1'
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    data = {
        'client_id': client_id,
        'client_secret': client_secret,
        'grant_type': 'client_credentials',
        'scope':'openid AdobeID'
    }
    response = requests.post(auth_url, headers=headers, data=data)
    return response.json().get('access_token', '')

 

# Combine PDFs using Adobe PDF Services API
def combine_pdfs(access_token, input_file1, input_file2, output_file):
    api_url = 'https://pdf-services.adobe.io/operation/combinepdf'
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {access_token}'
    }

 

    data = {
        "inputs": [
            {"url": f"file://{input_file1}"},
            {"url": f"file://{input_file2}"}
        ],
        "output": {"url": f"file://{output_file}"}
    }

 

    response = requests.post(api_url, headers=headers, data=json.dumps(data))

 

    if response.status_code == 200:
        print(f"Combined PDF saved to: {output_file}")
    else:
        print(f"Error combining PDFs. Status code: {response.status_code}, Response: {response.text}")

 

# Get access token
token = get_access_token(client_id, client_secret)

 

# Combine PDFs
combine_pdfs(token, input_file1, input_file2, output_file)

Raymond Camden
Community Manager
Community Manager
January 30, 2024

You are missing the x-api-key header which should be your clientID value.

Also, files don't work that way for jobs. You need to upload them first and get the asset IDs, or use external files via the cloud storage systems we support.

jane-e
Community Expert
Community Expert
January 29, 2024

@irfan35097768aoc2 

 

You posted to Using the Community, which is for questions about the forums. Your link goes to Adobe PDF Services API, so I've moved your post to the Acrobat Services API forum for you. Let us know if this is the right place for your question.

 

Jane