Authenticate User with OpenID Authentication

{ authenticateUserOPENID }

Generates a Pyramid access authentication token using OpenID authentication parameter map

Method

/API2/auth/authenticateUserOPENID

  • API Section: /API2/auth
  • API Version: 2.0
  • From Release: 2020.20
  • Can be used by Non-admin accounts
  • Method operates via POST actions only.
  • Input Parameters

    Name

    parameterMap

    Type

    string

    Description

    The OpenID parameter map serialized to String representation

    Output Response

    Successful Result Code

    200

    Description of Response Type

    The response is the security token as a base64 string. It is usually stored in a cookie.

    Notes

    The security token is a string that needs to be embedded in every API call to ensure the API calls are authorized. If saved as a cookie in a web browser, it can be used (for the authenticated user) to auto-login into the application. The assumption is that the user has already authenticated via OpenID before attempting to authenticate into Pyramid.

    Examples
    Authenticate User with OpenID:

    This example demonstrates how to authenticate a user using OpenID.

    // URL of the Pyramid installation and the path to the API 2.0 REST methods
    var pyramidURL = "http://mysite.com/api2/";
    
    // The response from the OpenId authentication
    var openIdToken = "YOUR_OPEN_ID_TOKEN(RESPONSE)";
    
    //generic method for running REST methods
    function callApi(path, data, parseResult = true) {
    	var xhttp = new XMLHttpRequest();
    	xhttp.open("POST", pyramidURL + path, false);
    	xhttp.send(JSON.stringify(data));
    	if (parseResult) {
    		return JSON.parse(xhttp.responseText);
    	} else {
    		return xhttp.responseText;
    	}
    }
    
    //calling the API to receive the Pyramid token
    let pyramidToken = callApi(
    	"auth/authenticateUserOPENID",
    	{
    		data: {
    			parameterMap: {
    				id_token: openIdToken,
    				state: "preferred_username",
    			},
    		},
    	},
    	false
    );
    console.log("fetch: " + pyramidToken);