Application & Process Automation
- Getting Started
- Common Usage Scenarios
- Troubleshooting
- Using Custom IDs
- API Method Reference
-
- GetPrograms
- GetForms
- GetFormSchema
- GetProjects
- GetProjectsByNumber
- GetProjectsByData
- CreateNewProject
- GetAllProjectData - Admin only
- GetProjectData
- SetProjectData
- GetActiveAttachment
- GetAttachmentAsAdmin – Admin only
- SetProjectAttachment
- SetAttachmentMetadata
- GetAttachmentMetadata
- SubmitProject
- GetStatusList – Admin only
- GetCustomListChoices
- GetProjectStatusHistory – Admin only
- SetProjectStatus – Admin only
- GetExportProject – Admin only
- CreateMfaSessionToken
- DeleteMfaSessionToken
- SetAssignee
- SetProjectOwner
- GetInquiryThreads – Admin Only
- GetNotesInInquiryThread – Admin Only
- SetInquiryNote – Admin Only
- SetInquiryThreadStatus – Admin Only
- SetInquiryThreadExternalId – Admin Only
- SetProjectStatusReportAs – Admin only
- Code Samples
CreateMfaSessionToken
Creates a new Multi-Factor Authentication Session Token (MST). Users with Multi-Factor Authentication (MFA) enabled on their accounts must provide either a valid MST or a valid Time-based-One-Time-Password (TOTP) from their authenticator application in order to make any API request. In order to make this request, the user must have MFA enabled on their account and must provide a TOTP as described in “Authentication & Access”. Note that this is the one request for which a TOTP is the only valid second authentication factor; that is, you cannot use an existing MST as authentication to create a new MST. When you create a new MST, any existing MST will be deleted.
HTTP verb: Post
Required inputs: None
HTTP verb: Post
Required inputs: None
<?xml version="1.0"?>
<CreateMfaSessionTokenRequest ExpiresAfterMinutes="60" />
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://service.powerclerk.com/api/v1/">
<xs:element name="CreateMfaSessionTokenRequest">
<xs:complexType>
<xs:attribute name="ExpiresAfterMinutes" type="xs:float" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>
<CreateMfaSessionTokenResponse>
<MfaSessionToken
TokenValue="ec89e8da-bcd5-46ae-84c9-eef928878230"
ExpirationTimeUtc="2019-04-23T21:24:52.2841505+00:00"
TokenId="V1YQV0D01MXW" />
</CreateMfaSessionTokenResponse>
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://service.powerclerk.com/api/v1/">
<xs:element name="CreateMfaSessionTokenResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="MfaSessionToken">
<xs:complexType>
<xs:attribute name="TokenValue" type="xs:string" use="required" />
<xs:attribute name="ExpirationTimeUtc" type="xs:dateTime" use="required" />
<xs:attribute name="TokenId" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:float" name="SchemaVersion"/>
</xs:complexType>
</xs:element>
</xs:schema>
Response XML Attributes
<MfaSessionToken>
AttributesTokenValue
– The value of the generated token. This is the value you should pass in the Mfa-Session-Token header when using the MST to authenticate in the PowerClerk API.ExpirationTimeUtc
– The expiration timestamp of the generated token in UTC time.TokenId
– The public ID of the generated token. This is how you will refer to the MST if you want to delete it via the DeleteMfaSessionToken API.
// Create an MFA Session Token for the user with the given username,
// password, and apiKey that expires in "expiresAfterMinutes" minutes
// after creation.
public Tuple<string, string, string> CreateMfaSessionToken(
string username,
string password,
string apiKey,
int expiresAfterMinutes)
{
// Create an XML request payload that creates an MFA Session Token for
// use with MFA-enabled PowerClerk account API requests
XNamespace ns = "http://service.powerclerk.com/api/v1/";
XDocument xDocument = new XDocument(
new XElement(ns + "CreateMfaSessionTokenRequest",
new XAttribute("ExpiresAfterMinutes", expiresAfterMinutes)));
XmlDocument requestPayload = new XmlDocument();
using (XmlReader xmlReader = xDocument.CreateReader())
{
requestPayload.Load(xmlReader);
}
// Generate url and execute request with the XML payload we created earlier
string url = "/Accounts/MfaSessionTokens";
XDocument xmlResponse =
MakePostRequest(BaseUrl + url, username, password, apiKey, requestPayload);
XElement tokenElement = xmlResponse.Descendants(ns + "MfaSessionToken").ToList()[0];
string tokenId = tokenElement.Attribute("TokenId").Value;
string tokenValue = tokenElement.Attribute("TokenValue").Value;
string expirationTimeUtc = tokenElement.Attribute("ExpirationTimeUtc").Value;
return new Tuple<string,string,string>(tokenId, tokenValue, expirationTimeUtc);
}
See Chapter Code Samples for MakePostRequest sample code.
What’s Next?