This documentation is for WSO2 IoT Server 3.1.0. View the documentation for the latest release.
Configuring IoTS with WSO2 API Manager - IoT Server 3.1.0 - WSO2 Documentation
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

WSO2 IoTS is prepackaged with WSO2 API Manager (WSO2 API-M) features and your device APIs are published to the internal API-M in the developer/testing environment. In a production environment publishing the device APIs on WSO2 IoTS will not be sufficient. Therefore, you need to integrate WSO2 IoTS with WSO2 API-M. Follow the steps given below to publish device APIs to the externally configured WSO2 API-M that is deployed on one node:

  1. Port offset WSO2 API-M by 2 and start the server. There are two ways to set an offset to a port:
    • Pass the port offset to the server during startup. The following command starts the server with the default port incremented by 2.

      ./ -DportOffset=10
    • Set the ports section of the <APIM_HOME>/repository/conf/carbon.xml file as follows: <Offset>2</Offset>
      Once you have port offset, start WSO2 API-M using the following command.

  2. Both WSO2 API-M and WSO2 IoTS must use the same database:
    1. Open the master-datasources.xml file that is in the <IoTS_HOME>/repository/conf/datasources directory and configure the WSO2_CARBON_DB and WSO2AM_DB datasources.
    2. Open the master-datasources.xml file that is in the <APIM_HOME>/repository/conf/datasources directory and configure the WSO2_CARBON_DB and WSO2AM_DB datasources.

    Example: The datasource settings for the WSO2_CARBON_DB datasource, if you are using MySQL as the database.

       <description>The datasource used for registry and user manager</description>
       <definition type="RDBMS">
             <validationQuery>SELECT 1</validationQuery>
  3. Configure WSO2 IoTS to identify the external WSO2 API-M.
    Open the api-manager.xml file that is in the <IoTS_HOME>/conf repository and configure the serverURL fields.

    • Each field is explained in the api-manager.xml file.
    • By default, <APIM_HTTPS_PORT> has been set to 9443. In step 1 above, the port offset was incremented by 2, therefore the default port value needs to be 9445.
    • Configure the ServerURL filed under the AuthManager tag as follows: https://<APIM_HOST>:<APIM_HTTPS_PORT>/services.

         <!-- Server URL of the Authentication service -->
         <!-- Admin username for the Authentication manager. -->
         <!-- Admin password for the Authentication manager. -->
         <!-- Indicates whether the permissions checking of the user (on the Publisher and Store) should be done via a
              remote service. The check will be done on the local server when false.
    • Configure the fields under the APIGateway tag. Each field is explained in the api-manager.xml file.

         <!-- The environments to which an API will be published -->
            <!-- Environments can be of different types. Allowed values are 'hybrid', 'production' and 'sandbox'.
      		     An API deployed on a 'production' type gateway will only support production keys.
      		     An API deployed on a 'sandbox' type gateway will only support sandbox keys.
      		     An API deployed on a 'hybrid' type gateway will support both production and sandbox keys. -->
            <!-- api-console element specifies whether the environment should be listed in API Console or not -->
            <Environment type="hybrid" api-console="true">
               <Name>Production and Sandbox</Name>
               <Description>Description of environment</Description>
               <!--Server URL of the API gateway.-->
               <!--Admin username for the API gateway.-->
               <!--Admin password for the API gateway.-->
               <!--Endpoint URLs for the APIs hosted in this API gateway.-->
         <!--Enable/Disable token caching at gateway node.-->
         <!--Enable/Disable API resource caching at gateway node.-->
         <!-- Header name can be configurable, as you preferred. When API invocation is restricted to access only
              for authorized domains, client request should send his domain, as the value of this header.
    • Configure the fields under the APIKeyValidator tag. 

         <!-- Server URL of the API key manager -->
         <!--Admin username for API key manager. -->
         <!-- Admin password for API key manager.-->
         <!-- Enable/Disable API key validation information caching at key-management server-->
         <!-- Expiry time for the apim key mgt validation info cache -->
         <!--Configurations related to enable thrift support for key-management related communication. 
             If you want to switch back to Web Service Client, change the value of "KeyValidatorClientType" to "WSClient".
             In a distributed environment:
              -If you are at the Gateway node, you need to point "ThriftClientPort" value to the "ThriftServerPort" value given at
               KeyManager node.
              -If you need to start two API Manager instances in the same machine, you need to give different ports to "ThriftServerPort"
               value in two nodes.
              -ThriftServerHost - Allows to configure a hostname for the thrift server. It uses the carbon hostname by default.
           	-Gateway use this parameter to connect key validation thrift service. 
         <!--  Scope used for marking Application Tokens. If a token is generated with this scope, they will be treated as Application Access Tokens -->
         <!-- Specifies the implementation to be used for KeyValidationHandler. Steps for validating a token can be controlled by plugging in a custom KeyValidation Handler -->
         <!-- Name of the token API -->
         <!-- This the API URL for revoke API. When we revoke tokens revoke requests should go through this
              API deployed in API gateway. Then it will do cache invalidations related to revoked tokens.
      	    In distributed deployment we should configure this property in key manager node by pointing
      	    gateway https( /http, we recommend users to use 'https' endpoints for security purpose) url.
              Also please note that we should point gateway revoke service to key manager
         <!-- Whether to encrypt tokens when storing in the Database
      	Note: If changing this value to true, change the value of <TokenPersistenceProcessor> to
      	org.wso2.carbon.identity.oauth.tokenprocessor.EncryptionDecryptionPersistenceProcessor in the identity.xml -->

      The port offset specified earlier in carbon.xml does not affect the ports of the Thrift client and server because Thrift is run as a separate server within WSO2 servers. Therefore, you must change the Thrift ports separately using <ThriftClientPort> and <ThriftServerPort> elements in the <APIM_HOME>/repository/conf/api-manager.xml file. For example, the following configuration sets an offset of 2 to the default Thrift port, which is 10397:

    • Configure the ServerURL field under the APIStore tag, as follows:  https://<APIM_HOST>:<APIM_HTTPS_PORT>/services
      Example: https://localhost:9453/services

    • Configure the URL field under the APIPublisher tag, as follows: https://<APIM_HOST>:<APIM_HTTPS_PORT>/publisher
      Example: https://localhost:9453/publisher

    • Configure the fields under the CORSConfiguration.


         <!--Configuration to enable/disable sending CORS headers from the Gateway-->
         <!--The value of the Access-Control-Allow-Origin header. Default values are API Store addresses, 
             which is needed for swagger to function.
         <!--Configure Access-Control-Allow-Methods-->
         <!--Configure Access-Control-Allow-Headers-->
         <!--Configure Access-Control-Allow-Credentials-->
         <!-- Specifying this header to true means that the server allows cookies (or other user credentials) 
              to be included on cross-origin requests. 
              It is false by default and if you set it to true then make sure that the Access-Control-Allow-Origin header 
              does not contain the wildcard (*) 
  4. Restart WSO2 API-M. Once you restart, WSO2 IoTS will publish the device APIs to the external API-M.

    To view the published APIs login to the external API store using admin as the username and the password:http://<APIM_HOST>:<APIM_HTTPS_PORT>/store

If you wish to configure WSO2 API-M on clustered environment, you need to configure it as mentioned under Configuring the connections among the components.

Additionally, you need to do the following configurations.

  • No labels