Postman & V8 API OAuth2 Confusion

I’m new to API programming and Postman and stuck trying to get Postman to talk with my SuiteCRM 8.1.3 instance.

I’ve followed: API Authentication

and

SuiteCRM V8 API Set Up For Postman

I’m stuck with the authorization aspect with Postman.

One thing all my URLs have a # such as https://crm.domain.net/#/home/about

When working with the URLs, should I include the # in the variable settings? It seems when I leave it out I get a 404 error. However, when I use it I get a 200 but a bunch of HTML returned output, not the expected records.

In Postman I entered in the Authorization Tab

  • Type: OAuth 2.0
  • Add Auth data to: Request Headers

Current Token

  • Access Token: Available Tokens / Access Token is blank.

  • Header Prefix: Bearer

  • Token Name: Postman

  • Grant Type: Password Credentials

  • Access Token URL: https://crm.domain.net/Api/access_token

  • Client ID: Client ID from the admin of SuiteCRM.

  • Client Secret: The password I created when making the Client ID.

  • Username: My username to enter SuiteCRM

  • Password: MY password to enter SuiteCRM

  • Client Authentication: Send as Basic Auth Header

I have the suitecrm.url & token.url set in the Environment

It would be nice to figure this out and add more clarity to the Postman setup document for others to easily understand and not waste time trying to figure out.

The guide that you are looking at is for SuiteCRM 7.x . It has not been updated yet for SuiteCRM 8.x
If you want to use api in SuiteCRM 8 your urls should include legacy
for example to get access_token your url will be
{{suitecrm.url}}/legacy/Api/access_token

I tried that, and I’m getting access denied. I’m knew to APIs and all this is really confusing without proper step-by-step documentation.

this sounds incorect as well. have you followed the steps on this guide ?

Yeah, I tried to follow that to the best of my ability.

I have the token properly created, the Client ID and Secret. Yet the documentation talks about Username and Password. What do I really need here?

Postman has updated and is different from most of the tutorials online, so I’m not sure of what I should be including and where.

With just the Client ID and Secret I’m getting 401 Unauthorized.

Here’s the debug log from the API test call for modules.

bash-4.4$ tail -f suitecrm.log
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] current_language is: en_us
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCacheMemcache
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCacheZend
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCacheWincache
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCacheAPC
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCacheMemcached
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Using cache backend SugarCacheMemcached, since 900 is less than 1000
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCacheFile
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCachesMash
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCacheRedis
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Found cache backend SugarCacheMemory
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Found language file: en_us.lang.php
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Found custom language file: en_us.lang.php
Tue Oct  4 06:22:49 2022 [291809][-none-][WARN] Configuration variable date.timezone is not set, guessed timezone UTC. Please set date.timezone="UTC" in php.ini!
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Query:SELECT id, name, symbol, conversion_rate FROM currencies WHERE status = 'Active' and deleted = 0
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Query Execution Time:9.5844268798828E-5
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Query:SELECT category, name, value FROM config
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Query Execution Time:0.00018000602722168
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Query:SELECT id FROM outbound_email WHERE type = 'system' AND deleted = 0
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Query Execution Time:5.6028366088867E-5
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Query:SELECT * FROM outbound_email WHERE id = 'a8e374b6-33cc-99d7-2c4e-6328fb6c55f9'
Tue Oct  4 06:22:49 2022 [291809][-none-][INFO] Query Execution Time:0.0001068115234375
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Hook called: ::after_entry_point
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Including module specific hook file for custom/modules
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Including Ext hook file for custom/application
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/slim.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/controllers.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/factories.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/globals.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/helpers.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/middlewares.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/params.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/services.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/validators.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/services.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom file is not exists: custom/application/Ext/Api/V8/beanAliases.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Custom routes file is not exists: custom/application/Ext/Api/V8/Config/routes.php
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Hook called: ::server_round_trip
Tue Oct  4 06:22:49 2022 [291809][-none-][DEBUG] Calling MySQLi::disconnect()

Hey,
You need to create OAuth2 Clients and tokens in Admin


Create New Password Client
image
While creating the client the secret that you enter is your ‘client_secret’
image
After saving you will get ID that is your ‘client_id’

In postman the username is any crm username and password is the password for the user that you set as username

Hope this helps