Professional Documents
Culture Documents
Overview
This article describes how to use custom hooks in the API Connect
v2018. Developer Portal to share application credentials with
Identity Provider (IdP) like IBM Security Access Manager.
Custom Hook
1. modulename_apic_app_create
Use the POST method and with the following URL and payload.
POST /apps HTTP/1.1
Host: {idp_hostname}
Accept: application/json
Content-Type: application/json; charset=iso-8859-1{
"id": {app_id},
"name": {app_name},
"title": {app_title},
"credential": {
"id": {cred_id},
"client_id": {client_id},
"client_secret": {client_secret}
}
"redirect_endpoints": [
{redirect_url_1},
{redirect_url_2}
]
}
2. modulename_apic_app_update
Use the PUT method and with the following URL and payload.
PUT /apps/{app_id} HTTP/1.1
Host: {idp_hostname}
Accept: application/json
Content-Type: application/json; charset=iso-8859-1{
"name": {app_name},
"title": {app_title},
"redirect_endpoints": [
{redirect_url_1},
{redirect_url_2}
]
}
3. modulename_apic_app_delete
Use the DELETE method and with the following URL and payload.
DELETE /apps/{app_id} HTTP/1.1
Host: {idp_hostname}
4. modulename_apic_app_clientid_reset
Use the PUT method and with the following URL and payload.
PUT /apps/{app_id}/credentials/{cred_id} HTTP/1.1
Host: {idp_hostname}
Accept: application/json
Content-Type: application/json; charset=iso-8859-1{
"client_id": {client_id},
"client_secret": {client_secret}
}
5. modulename_apic_app_clientsecret_reset
Use the PUT method and with the following URL and payload.
PUT /apps/{app_id}/credentials/{cred_id} HTTP/1.1
Host: {idp_hostname}
Accept: application/json
Content-Type: application/json; charset=iso-8859-1{
"client_secret": {client_secret}
}
7. modulename_apic_app_creds_create
Use the POST method and with the following URL and payload.
POST /apps/{app_id}/credentials/{cred_id} HTTP/1.1
Host: {idp_hostname}
Accept: application/json
Content-Type: application/json; charset=iso-8859-1{
"credential": {
"client_id": {client_id},
"client_secret": {client_secret}
}
}
8. modulename_apic_app_creds_delete
This hook is called when the credential is deleted. The IDP should
delete the credential object.
Use the DELETE method and with the following URL and payload.
DELETE /apps/{app_id}/credentials/{cred_id} HTTP/1.1
Host: {idp_hostname}
Accept: application/json
Content-Type: application/json; charset=iso-8859-1
9. modulename_apic_app_creds_update
This hook is called when the title of the credential is updated. The
IDP should update the credential object. This is no need to handle
this because the title of the credential is not important to the IDP.
How to create custom module
4. Prefix the function with your custom module name with the
following format moduleName_apic_app_create.
function app_cred_push_apic_app_create($node, $app) {
}
4. Troubleshoot
2. To view the logs, ssh into the portal server and run the following:
? sudo -i
? kubectl get poNAME
READY STATUS RESTARTS AGE
apic-portal-apic-portal-db-cljxp 2/2 Running
0 8d
apic-portal-apic-portal-nginx-664c6c5b59-r6pv7 1/1 Running
0 25d
apic-portal-apic-portal-www-q2wdj 2/2 Running
0 8d
ptl-backup-4pjvb-pfvqj 0/1
Completed 0 8d
ptl-backup-662vt-g2rn8 0/1
Completed 0 8d
ptl-backup-p54nf-j4ln7 0/1 Error
0 8d
ptl-list-backups-kvsx8-rn85l 0/1 Error
0 8d
ptl-list-backups-vr5rp-xs9xk 0/1
Completed 0 8d
3. Ensure that your PHP code can be compiled (no syntax error) —
because it will crash your portal site.
4. If you crash your portal site, you need to correct the error within
the container.
? kubectl -it exec apic-portal-apic-portal-www-q2wdj -c web bash
5. Go to the folder (as follows), edit and correct the error in the file.
? cd
/web/platforms/devportal-8.x-2018.4.1.7-20190910-0421/sites/{org
}.{catalog}.{portal-web-endpoint}/modules/{module-name}
for example:
? cd
/web/platforms/devportal-8.x-2018.4.1.7-20190910-0421/sites/thin
k-provider-organization.test.portal-web.think.org/modules/app-
cred-push-module