There can be web applications internally calling the OAuth secured APIs. Once web applications are published and accessed through the AppManager gateway, user is authenticated using the SAML SSO. In this feature, we can use the same SAML token generated by the App Manager gateway and get an OAuth2 access token by calling the token endpoints used by these APIs.
...
Once the web application is created on App Manager, it will wrap these details and generate a new consumer/secret key pair for the web application [WCk1, WCSk1]. Actual web application can use this consumer/secret key pair generated by the AppManager App Manager publisher, when it need to get an access token to call the registered APIs.
You can see the consumer/secret key pair generated by AppManager, once you go to App Manager, in the overview page of published application. See the image bellowapplications as depicted in the below image.
xxxxxx insert image here xxxxxx[2] AppManager
Invoking App Manager Token API from web app
App Manager itself provides a token API. Web applications need to call this token API with the consumer, /secret key pair [WCk1, WCSk1] given provided by the AppManagerApp Manager, when they need to get an access token for a particular API.
Note:
Info |
---|
This token API is deployed in the |
...
|
...
App Manager is running with |
...
a port offset, then the port defined inside the |
...
file needs to be changed accordingly. |
Example of invoking Use the following parameters and values to invoke AppManager Token API from Web-App to get the web application, to obtain an access token is given below..
Code Block | ||
---|---|---|
| ||
String apiAlias = "pizzashack"; |
...
String applicationToken = base64Encode(WCk1 + ":" + WCSk1); |
...
String payload = "grant_type=SAML2&scope=" + samlTokenId + "," + apiAlias; |
...
httpClient.doPost("http://localhost:8280/token", applicationToken, payload, "application/x-www-form-urlencoded"); |
...
- apiAlias need to be - the alias name given when registering the API details in AppManager App Manager publisher.
- applicationToken is - the base64 encoded value of consumer/secret key pair provided by AppManagerApp Manager.
- In String payload - the payload , it need needs to send the grant _ type and the scope value. Grant _ type need to be set as “SAML2”SAML2. Scope should contain the value of ‘samlTokenId’
samlTokenId
cookie andapiAlias
as comma separated strings. - " http://localhost:8280/token " is
httpClient.doPost - the token API provided by
AppManager. It need to change withApp Manager. Change it with the define port offset accordingly.