Search This Blog

Friday, March 15, 2024

BMXAA9549E - The API key token is invalid. Either the token may have expired or the token has been revoked by the administrator.

The API key was deleted from Maximo Manage after an installation or after a new user is created in Manage to test the post implementation. It is no longer possible to create a new user and change the password in Maximo core due to API Key error.


The following errors are generated in the Manage UserSynchAgent log:

Exception: [customer_system_hostname maxadmin] synched: status_code: 400 r.text Error 400: BMXAA9549E - The API key token is invalid. Either the token may have expired or the token has been revoked by the administrator.
2022-09-12 05:17:04,321 usersync-agent-manage INFO Attempt: 1 of 5
2022-09-12 05:17:34,332 usersync-agent-manage INFO Sync user maxadmin, status PENDING
2022-09-12 05:17:34,333 usersync-agent-manage INFO [customer_system_hostname maxadmin] Sync user url: https://hostname.mas-systemname-manage.svc/meaweb/es/MASSYNC/MASPERUSER?clientcert=1, method: POST, headers: {'content-type': 'application/json'}
2022-09-12 05:17:34,334 usersync-agent-manage INFO [customer_system_hostname maxadmin] Sync user data: {'_id': 'maxadmin', 'added': {'appId': 'manage', 'timestamp': '2022-09-11T18:38:39.979923'}, 'addresses': [], 'applications': {'assist': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'health': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'hputilities': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'iot': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'manage': {'sync': {'reason': '', 'state': 'PENDING', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'monitor': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'optimizer': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'predict': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'safety': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}, 'visualinspection': {'sync': {'reason': '', 'state': 'SUCCESS', 'timestamp': '2022-09-12T05:15:52.671155'}}}, 'displayName': 'MAXADMIN', 'emails': [{'primary': True, 'type': 'Work', 'value': 'user.name@domainname.com'}], 'entitlement': {'admin': 'NONE', 'alwaysReserveLicense': False, 'application': 'PREMIUM'}, 'familyName': '', 'givenName': '', 'issuer': 'local', 'owner': 'local', 'permissions': {'systemAdmin': False, 'userAdmin': False}, 'phoneNumbers': [], 'preferences': {'locale': {'country': None, 'language': None}, 'timezone': None}, 'sync': {'status': 'PENDING', 'timestamp': '2022-09-12T05:15:52.457726'}, 'title': '', 'token': '1000:d8a82d04c7981f0c1fd3c52d45ec14c0a64d6620a1be861f:a9bc1a2048612c00036b613716d1057452a72cb4a256cfce', 'updated': {'id': 'vPtB9WZdfm5USXuc9i57KpWL0jKUy3jO', 'timestamp': '2022-09-12T05:15:52.457726'}, 'username': 'maxadmin', 'workspaces': {'customer_system_hostname': {'applications': {'manage': {'role': 'MANAGEUSER'}}, 'permissions': {'workspaceAdmin': False}}}}
2022-09-12 05:17:34,417 usersync-agent-manage INFO [customer_system_hostname maxadmin] Sync user response: r.status: 400, r.text: Error 400: BMXAA9549E - The API key token is invalid. Either the token may have expired or the token has been revoked by the administrator.
2022-09-12 05:17:34,418 usersync-agent-manage INFO [customer_system_hostname maxadmin] synched: status_code: 400 r.text Error 400: BMXAA9549E - The API key token is invalid. Either the token may have expired or the token has been revoked by the administrator.
2022-09-12 05:17:34,418 usersync-agent-manage ERROR [maxadmin] Got exception: [customer_system_hostname maxadmin] synched: status_code: 400 r.text Error 400: BMXAA9549E - The API key token is invalid. Either the token may have expired or the token has been revoked by the administrator.
2022-09-12 05:17:34,418 usersync-agent-manage ERROR Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/mas/utils/usersync/usersync.py", line 242, in doSync
agent.syncUser(user)
File "/opt/ibm/usersync/agent.py", line 75, in syncUser
raise Exception(errMsg)

Symptom

The MAS "usersync" pod should show all the affected users.





Cause

The APIKEY in MAS Manage is invalid and needs to be regenerated.

Environment

MAS Manage

Diagnosing The Problem

Running the following SQL query confirms that the table is empty.

select * from apikeytoken;


Also checked to ensure that 2 default users like MAXADMIN and MXINTADM are already synchronised with Manage.

Resolving The Problem

1. Before actioning step #2,  get a copy of the apikeytoken records (with other fields besides apikey)  ofclientcert=1 

Run SQL command:

select * from apikeytoken where clientcert=1

2. R- run the insertapikey commands as list below to re-insert the records, then make a copy of the apikeytoken records for those clientcert=1


Execute the remediation step for the APIKEY by running the following commands from the maxinst POD:

cd /opt/IBM/SMP/maximo/tools/maximo

./insertapikey.sh -v'${MANAGE_APIKEY}' -m'prop:mxe.int.dfltuser'
./insertapikey.sh -v'${MANAGE_APIKEY}, O=cert-manager' -m'prop:mxe.int.dfltuser'
./insertapikey.sh -v'${HEALTH_APIKEY}' -m'prop:mxe.MASUserSyncAgentUser'
./insertapikey.sh -v'${HEALTH_APIKEY}, O=cert-manager' -m'prop:mxe.MASUserSyncAgentUser'
./insertapikey.sh -v'${PMI_APIKEY}' -m'prop:mxe.PMIUser'
./insertapikey.sh -v'${PMI_APIKEY}, O=cert-manager' -m'prop:mxe.PMIUser'
./insertapikey.sh -v'${PMI_APIKEY_NEW}, O=cert-manager' -m'prop:mxe.PMIUser'
./insertapikey.sh -v'${PMI_APIKEY_NEW}' -m'prop:mxe.PMIUser'
./insertapikey.sh -v'${EU_APIKEY}' -m'prop:hputilities.health.user'
./insertapikey.sh -v'${EU_APIKEY}, O=cert-manager' -m'prop:hputilities.health.user'
./insertapikey.sh -v'${EU_APIKEY_NEW}, O=cert-manager' -m'prop:hputilities.health.user'
./insertapikey.sh -v'${EU_APIKEY_NEW}' -m'prop:hputilities.health.user'
Verify that the environment is operational following the APIKEY regeneration.


IBM Maximo Application Suite - updatedb fails with dbchange ScriptFailure

 Reactivation of Manage application fails. Adding the IBM Maximo Health, Safety & Environment and Spatial add-on components and reactivating Manage application results in "dbchange#ScriptFailure" error. 

Logs show error messages as below log entries:

Example 1:
CREATE PROCEDURE PLUSG_AS_6 ( v_pOrgID VARGRAPHIC(8) ) LANGUAGE SQL BEGIN DECLARE SQLSTATE CHAR(5) DEFAULT '00000'; 
// Failed.
ERROR: BMXAA7025E -- Script failed while running.;
BMXAA8313E -- A statement failed to execute inside a freeform statement. See the nested exception.;
DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=PLUSG_AS_7;PROCEDURE, DRIVER=4.26.14
at psdi.oilandgas.en.V7110_97(V7110_97.java: 55)
aused by: BMXAA8313E -- A statement failed to execute inside a freeform statement. See the nested exception.;
DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=PLUSG_AS_7;PROCEDURE, DRIVER=4.26.14
at psdi.oilandgas.en.V7110_97(V7110_97.java: 55)
Caused by: DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=PLUSG_AS_7;PROCEDURE, DRIVER=4.26.14
       at com.ibm.tivoli.maximo.dbmanage.connection.LoggingStatement(LoggingStatement.java: 145)
        ... 32 more
rollback;
Example 2:
insert into crontaskdef (crontaskname, classname, description, crontaskdefid, accesslevel, langcode, hasld) select crontaskname, classname, description, crontaskdefid, accesslevel, langcode, hasld from zxcrontaskdef
;
// Failed.
Example 3:
- BMXAA9115I -- The script code inserted only unique records into table CRONTASKDEF.
insert into crontaskdef (crontaskname, classname, description, crontaskdefid, accesslevel, langcode, hasld) values (?, ?, ?, ?, ?, ?, ?)
;
ReportImport, psdi.app.report.ReportImportCronTask, Crontask to import report designs., 424, FULL, EN, 0
// Failed.
Example 4:
-- Product: IBM Maximo Oil and Gas, Last release database version:V7620-96, Next release dabatabase version:V8000-03, DBOILANDGAS:V8000-3
-- WARNING: Property file V8000_props does not exist. Continuing.......
-- WARNING: File classnames.dat for resetting maxobject/maxattribute table does not exist. Continuing.......
-- WARNING: File services.dat for resetting maxservice table does not exist. Continuing.......
-- Product: IBM Maximo Oil and Gas extension update starts...
-- Product: IBM Maximo Oil and Gas extension update complete: SUCCESSFUL
-- Report Version: Last report version for IBM Maximo Health, Safety and Environment not found in product xml, checking report version xml.
-- MESSAGES_PROC Product: DBHSE did not switch over
-- Product: IBM Maximo Health, Safety and Environment, Last release database version:V7620-02, Next release dabatabase version:V8000-01, DBHSE:V7620-1
-- WARNING: Property file V8000_props does not exist. Continuing.......
-- Product: IBM Maximo Health, Safety and Environment script updatedb process starts...
Running scripts for product: IBM Maximo Health, Safety and Environment from #1 to #2, fileVersion: V7620, varName: DBHSE, productDir: hse
             Calling the class file : psdi.hse.en.V7620_02 Mon Apr 04 11:47:03 GMT 2022
   -------------------------------------------------------------------
             Calling the dbchange file : V7620_02 Mon Apr 04 11:47:03 GMT 2022
   -------------------------------------------------------------------
/*
 * freeform: Update Apphelp Links for HSE.
 */
update maxpresentation set presentation = REPLACE(presentation, 'com.ibm.oil.doc', 'com.ibm.hse.doc') where app not in ('LIBRARY','REPLIBRARY')
;

// Failed.

ERROR: BMXAA7025E -- Script failed while running.;
BMXAA8313E -- A statement failed to execute inside a freeform statement. See the nested exception.;
com.ibm.tivoli.maximo.dbmanage.MXExceptionWithDefault: scriptrun#ColumnNameTooLong;
Attributename value from dbc file is longer than the allowed length for a database column name;
DB2 SQL Error: SQLCODE=-433, SQLSTATE=22001, SQLERRMC=<?xml version="1.0" encoding="UTF-8"?>
Example 5:
-- BEGINUPDATEDBERROR
-- Product: IBM Maximo Spatial
-- Error running script: V7603_02
-- UPDATEDBFILE: V7603_02.dbc
-- Script: Error
rollback
;
Example 6:
/*
 * freeform: Create automation scripts Spatial Auto Create
 */
insert into autoscript (autoscript, status, scheduledstatus, comments, ownerid, ownername, ownerphone, owneremail, createdbyid, description, orgid, siteid, "ACTION", "SOURCE", createddate, version, category, statusdate, changedate, createdbyphone, createdbyname, createdbyemail, owner, createdby, changeby, autoscriptid, hasld, langcode, binaryscriptsource, scriptlanguage, userdefined, loglevel, rowstamp, interface, active) values('AUTO_CREATE_SPATIAL_SR_SAVE_ADD', 'Draft', NULL, NULL, NULL, NULL, '(617) 555-9017', 'm.wilson@helwig.com', NULL,'Auto Create Spatial when the Service Request is created.', NULL, NULL, NULL, '/*Sample script '||CHR(13) || CHR(10) || 'Automatically run Auto Create Spatial when the Service Request is created. */'||CHR(13) || CHR(10) || ''||CHR(13) || CHR(10) || 'ticketid = mbo.getString("ticketid");'||CHR(13) || CHR(10) || 'println( "Auto Creating SR Spatial");'||CHR(13) || CHR(10) || 'println("TICKETID: "+ticketid );'||CHR(13) || CHR(10) || 'println("SiteID: "+ticketid);'||CHR(13) || CHR(10) || 'var success = mbo.autoCreateSpatial(true);'||CHR(13) || CHR(10) || 'if (success) {'||CHR(13) || CHR(10) || '    println("SR Spatial successfully created");'||CHR(13) || CHR(10) || '} else {'||CHR(13) || CHR(10) || '    println("SR Spatial creation failed");'||CHR(13) || CHR(10) || '    mbo.getThisMboSet().save();'||CHR(13) || CHR(10) || '    warngroup = "plussgis";'||CHR(13) || CHR(10) || '    warnkey = "autocreate_nofeats_placed_workorderid";'||CHR(13) || CHR(10) || '    warnparams = [ticketid]'||CHR(13) || CHR(10) || '}', current timestamp, NULL, NULL, current timestamp, current timestamp, '(617) 555-9017', NULL, 'm.wilson@helwig.com', 'WILSON', 'WILSON', 'WILSON', NEXTVAL FOR AUTOSCRIPTSEQ, 0, 'EN', HEXTORAW(''), 'javascript', 1, 'INFO', '', 0, 0)
;

// Failed.

ERROR: BMXAA7025E -- Script failed while running.;
BMXAA8313E -- A statement failed to execute inside a freeform statement. See the nested exception.;
DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=CHR;FUNCTION, DRIVER=4.26.14

Resolving The Problem

In the JDBC configuration resource for Manage application, over IBM Maximo Application Suite Administration UI you need to add the below parameters:
currentSchema=<schema name>;currentFunctionPath=<schema name>,SYSIBM,SYSFUN,SYSPROC,SYSIBMADM;
Final JDBC connection URL is:
jdbc:db2://<host>:<port>/<db name>:currentSchema=<schema name>;currentFunctionPath=<schema name>,SYSIBM,SYSFUN,SYS

Reference Link :https://www.ibm.com/support/pages/node/6573217

MAS and Manage custom resources are not reconciled

  After a change was applied to IBM Maximo Application Suite (MAS) or IBM Maximo Manage, the custom resources are not reconciled. For exampl...