'IBM Worklight version 8.0 - Forbidden Error while accessing token
Receiving below error while accessing token:
WLAuthorizationManager.obtainAccessToken()
.then(
function (accessToken) {
console.log(accessToken);
console.log("Connected to MobileFirst Server")
WL.Logger.debug("Connected to MobileFirst Server");
},
function (error) {
console.log(error);
console.log("Failed to connect to MobileFirst Server");
WL.Logger.debug("Failed to connect to MobileFirst Server");
}
);
Response:
errorCode: "403"
errorMsg: "Forbidden"
responseHeaders: {connection: '[Keep-Alive]', content-length: '[199]', content-type: '[text/html; charset=iso-8859-1]', date: '[Thu, 21 Apr 2022 07:29:35 GMT]', keep-alive: '[timeout=120, max=1840]', …}
responseText: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don't have permission to access this resource.</p>\n</body></html>\n"
status: 403
statusText: "Forbidden"
Details: IBM Worklight platform version: '8.0.0.00-20190910-142437'
Any help will be appreciated. Thanks!
Solution 1:[1]
The fact that you are getting an HTML response indicating the 403 and this happens when the apk is replaced, points to a possible network policy or webserver blocking a PUT request to
http://<host>:<port>/mfp/api/registration/v1/self/<clientid>
The reasons why this could be the cause are:
- MFP server does not respond with HTML. MFP server responds only with JSON. The response seen in your case is a custom HTML.
- When you install an apk fresh and connect to the server, the request that fires is
POST http://<host>:<port>/mfp/api/registration/v1/self, while aPUT http://<host>:<port>/mfp/api/registration/v1/self/<clientid>fires when the apk is updated (or overwritten).
The other remote possibility is, you have application authenticity protection enabled in the server that is not working in case of the older apk. However, the chances of this being the case is near zero, as the error message returned gives a clear indication of the issue and it would not have worked in case of a fresh install too.
I would suggest you verify if your network policy does not allow PUT requests.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vivin K |
