Get service information from secure Web service

To access a secure Web service, including its specification, you need an access token issued on behalf of an authorized user.

You can get the token using the gettoken tool and provide it in the URL query string to get the OpenAPI specification.

The following steps describe the process.

  1. Use the gettoken tool to get the access token.
    Line breaks have been added to the command example to improve readability.
    fglrun GetToken.42r password -u user -p mypw 
    --idp https://host:port/gas/ws/r/services/GeneroIdentityProvider
    --savetofile mytoken.json myWSScope
    Where:
    1. The password command is used to get an access token on behalf of an authenticated user.
    2. The user name and password provided (-u user -p mypw) is that of a registered user in the IdP.
    3. The URL of the Genero Identity Provider (GIP) is specified in the --idp option.
    4. mytoken.json is the file name where the access token is saved.
    5. myWSScope is the scope of the service required in the token.
    Note: The access token is valid for 10 minutes.

    For further information, see the GetToken page in the Genero Application Server User Guide.

  2. Add the token in the Web service URL query string to get the specification.
    https://host:port/gas/ws/r/group/xcf/resource?openapi.json&access_token=token
    The OpenAPI specification is displayed in the browser formatted in JSON. You can copy and paste the output and save to a file. The stub file can be generated as described in Get service information from Web service.
  3. Or alternatively, you can use the token with the fglrestful tool to generate the stub.
    fglrestful -o clientStub http://host:port/gas/ws/r/group/xcf/resource?openapi.json -t token
    Where:
    1. clientStub specifies the file name of the stub in the output (-o) option.
    2. The URL of the Web service is specified with the query string ?openapi.json to get the specification file.
      Note: The "MyService" REST service must be running on the specified port in order to provide the service information.
    3. The token is specified in the token (-t) option.

    The clientStub.4gl generated from the specification contains the complete code to manage calls made by client applications to the Web service resources. You need to compile and link the module into your Genero REST client application. For details, see Call the stub functions.