You are here

You are here

Authenticate with User Keys

Authentication with keys allows you to connect to the API with a userkey generated by the SpringCM user interface. 

SpringCM allows custom buttons to be added to the SpringCM UI's menu drop downs and toolbar. To customize the menu, log in as an administrator and then navigate to View and then Customize Menu. Next click New Menu Item and you should see a screen similar to Figure 6. Make sure to check the box labeled Add User Key to URL for SpringCM to generate a user key in the context of the logged in user and pass it on the query string. Checking the Add Selection to URL box will pass the documents or folder selected on the query string as well, as it may be needed by your third party application. After saving the configuration on this screen you may optionally choose View and then Customize Toolbar if you want your custom button to show up on the toolbar as well as the menu drop down.

When the button is clicked you will notice that a parameter named userkey is passed on the query string, which is a token as well as a second parameter called uEmail that is the current user's email address. These two parameters can be used to authenticate to the SOAP API in the context of the logged user by calling the AuthenticateWithKeys method which takes the following parameters:

  • userName - This is the SpringCM username, which is the user's email address. The value of the uEmail query string parameter is passed as this parameter.
  • userKey - The user key from the query string.
  • apiKey - Your SpringCM API Key

The method will return a token in the context of the logged in user than can be used for subsequent API calls.

custombuttonuserkey.png

The following code sample shows how to retrieve a the userkey and uEmail parameters passed from a SpringCM custom button and use them to authenticate to the API.

Vertical Tabs

c#
SpringCMServiceSoapClient service = new SpringCMServiceSoapClient();
string token = service.AuthenticateWithKeys(<username>,<userKey>, <your api key>);
java
SpringCMServiceSoapProxy springCMService = new SpringCMServiceSoapProxy();
String token = springCMService.authenticateWithKeys(<username>,<userkey>,<apikey>);
php
<?php
// A SpringCM custom button puts the selected items on the query
// string in the format Selection=Document,<document id>;
// The document's ID will be needed later so we remove the labeling here
$document = str_replace('Document,', '', $_GET['Selection']);
$document = rtrim($document, ';');
// Adding the User Key to the query string puts two parameters in the URL: the user's
// email and a generated user key
$user_id = $_GET['uEmail'];
$user_key = $_GET['userkey'];
// Get a SpringCM session using AuthenticateWithKeys
$springcm = new
SoapClient("https://soapna11.springcm.com/atlas/webservices/v201308/SpringCMService.asmx?wsdl");
$auth_result = $springcm->AuthenticateWithKeys( array (
'userName'=>$user_id,
'userKey'=>$user_key,
'apiKey'=>'<your api key>' ));
// The AuthenticateWithKeysResult is a wrapper around the token
$token = $auth_result->AuthenticateWithKeysResult;
?>