Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
571 Weergaven

I am trying to build a custom integration between Salesforce and Odoo 16 Enterprise using a custom module and API key-based authentication.

What I’ve Done:

  • Created a custom module with a @http.route('/sf/get_products', auth='api_key', type='json', methods=['POST'], csrf=False)
  • Created a boolean field sfcost on product categories, used to filter products returned in the response
  • Generated an API key from an Internal User (with Inventory/User access)
  • Set auth_api_key = True in odoo.conf
  • Restarted the Odoo service fully

Problem:

Despite all correct headers and method (Authorization: Bearer <key>, Content-Type: application/json, POST), Odoo always returnsodoo.exceptions.AccessDenied: Access Denied


I even created a test route /sf/ping to just return the user name and still get AccessDenied.


Avatar
Annuleer

Can you elaborate on auth='api_key' since that's not actually a thing

Beste antwoord

hii,

Enable API Key Authentication in odoo.conf

You're correct to set:
auth_api_key = True

Make sure it is not commented out, and Odoo has been restarted after this change.

Use the Correct HTTP Header

For auth='api_key', Odoo expects the header exactly like this:
Authorization: Bearer <API_KEY>

API Key Must Belong to a User with Correct Group Access

You mentioned the user has Inventory / User access. That’s good for product data. But make sure this user also has access to "Technical Features" or is in the group that can access the endpoint logic (e.g., if your route does ORM queries).

Also:

  • Check that the API key was generated for an Internal user, not a portal or public user.
  • Confirm the key is still active and tied to the right user.

This is case-sensitive, and no extra space or typo is tolerated.

Test with a minimal route:
@http.route('/sf/ping', auth='api_key', type='json', methods=['POST'], csrf=False)

def ping(self, **kwargs):

    return {"user": request.env.user.name}

Test with curl:
curl -X POST https://yourdomain.com/sf/ping \

  -H "Authorization: Bearer <your_api_key>" \

  -H "Content-Type: application/json" \

  -d '{}'


Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
jun. 25
279
1
jun. 25
584
1
mei 25
1147
0
mrt. 25
665
1
dec. 24
3643