Configuring the single sign-on API is fairly simple: Navigate to wp2print>>Settings then select the "Single Sign-on" tab. Check the checkbox to enable the Single Sign-on API and enter the API Key that both the external site and wp2print will use for calculating hash values. There are no minimum length or content requirements for the API Key so you may use whatever Key you choose. It is crucial that the external site use the same Key in all API calls and hash calculations.
External websites can test whether an account already exists for a given username via the exists method from the Single Sign-On API . The external website should assemble a FORM and POST this to the wp2print site. The FORM should contain the following items:
<form action="[URL for wp2print site]" method="POST">
<input type="hidden" name="method" value="exists">
<input type="hidden" name="user" value="[username in wp2print site]">
<input type="hidden" name="time" value="[unix time]">
<input type="hidden" name="hash" value="[hash]">
<input type="submit" value="SUBMIT">
</form>
If the user account already exists, you will receive response: TRUE
If the user account does not exist, you will receive response: FALSE
External websites can create a new user account in wp2print sites by using the data method of the Single Sign-On API . The external website should assemble a FORM and POST this to the wp2print site. The FORM must contain first 5 elements as shown below. All the other FORM elements are optional.
Note that the value for the FORM field "user" = "admin". The key field used to identify the wp2print account to be created is the email field.
<form action="https://[mydomain.com]" method="POST">
/* Required fields */
<input type="hidden" name="method" value="data">
<input type="hidden" name="user" value="admin">
<input type="hidden" name="time" value="[unix time]">
<input type="hidden" name="hash" value="[hash]">
<input type="hidden" name="email" value="[Email address of new user account in wp2print]">
/* End required fields */
/* Optional fields */
<input type="hidden" name="firstName" value="[New value]">
<input type="hidden" name="lastName" value="[New value]">
<input type="hidden" name="billing_first_name" value="[New value]">
<input type="hidden" name="billing_last_name" value="[New value]">
<input type="hidden" name="billing_company" value="[New value]">
<input type="hidden" name="billing_address_1" value="[New value]">
<input type="hidden" name="billing_address_2" value="[New value]">
<input type="hidden" name="billing_city" value="[New value]">
<input type="hidden" name="billing_postcode" value="[New value]">
<input type="hidden" name="billing_country" value="[ISO 2-character code for new country]">
<input type="hidden" name="billing_state" value="[ISO 2-character code for new state]">
<input type="hidden" name="billing_email" value="[New value]">
<input type="hidden" name="billing_phone" value="[New value]">
<input type="hidden" name="shipping_first_name" value="[New value]">
<input type="hidden" name="shipping_last_name" value="[New value]">
<input type="hidden" name="shipping_company" value="[New value]">
<input type="hidden" name="shipping_address_1" value="[New value]">
<input type="hidden" name="shipping_address_2" value="[New value]">
<input type="hidden" name="shipping_city" value="[New value]">
<input type="hidden" name="shipping_postcode" value="[New value]">
<input type="hidden" name="shipping_country" value="[ISO 2-character code for new country]">
<input type="hidden" name="shipping_state" value="[ISO 2-character code for new state]">
<input type="hidden" name="groupid" value="[numeric groupID]">
/* End optional fields */
<input type="submit" value="SUBMIT">
</form>
External websites can automatically log users in to wp2print sites by using the login method from the Single Sign-On API . The external website should assemble a FORM and POST this to the wp2print site. The FORM should contain the following items:
<form action="[URL for wp2print site]" method="POST">
<input type="hidden" name="method" value="login">
<input type="hidden" name="user" value="[username in wp2print site]">
<input type="hidden" name="time" value="[unix time]">
<input type="hidden" name="hash" value="[hash]">
<input type="submit" value="SUBMIT">
</form>
External websites can update a user's account data in wp2print sites by using the data method from the Single Sign-On API. The external website should assemble a FORM and POST this to the wp2print site. The FORM must contain first 5 elements as shown below. All the other FORM elements are required only for those fields that are to be updated.
Note that the value for the FORM field "user" = "admin". The key field used to identify the wp2print account to be updated is the wp2print e-mail address field.
It is not possible to update the wp2print username field or the wp2print e-mail field for the user:
<form action="https://[mydomain.com]" method="POST">
/* Required fields */
<input type="hidden" name="method" value="data">
<input type="hidden" name="user" value="admin">
<input type="hidden" name="time" value="[unix time]">
<input type="hidden" name="hash" value="[hash]">
<input type="hidden" name="email" value="[Email address of user account in wp2print]">
/* End required fields */
/* Optional fields */
<input type="hidden" name="firstName" value="[New value]">
<input type="hidden" name="lastName" value="[New value]">
<input type="hidden" name="billing_first_name" value="[New value]">
<input type="hidden" name="billing_last_name" value="[New value]">
<input type="hidden" name="billing_company" value="[New value]">
<input type="hidden" name="billing_address_1" value="[New value]">
<input type="hidden" name="billing_address_2" value="[New value]">
<input type="hidden" name="billing_city" value="[New value]">
<input type="hidden" name="billing_postcode" value="[New value]">
<input type="hidden" name="billing_country" value="[ISO 2-character code for new country]">
<input type="hidden" name="billing_state" value="[ISO 2-character code for new state]">
<input type="hidden" name="billing_email" value="[New value]">
<input type="hidden" name="billing_phone" value="[New value]">
<input type="hidden" name="shipping_first_name" value="[New value]">
<input type="hidden" name="shipping_last_name" value="[New value]">
<input type="hidden" name="shipping_company" value="[New value]">
<input type="hidden" name="shipping_address_1" value="[New value]">
<input type="hidden" name="shipping_address_2" value="[New value]">
<input type="hidden" name="shipping_city" value="[New value]">
<input type="hidden" name="shipping_postcode" value="[New value]">
<input type="hidden" name="shipping_country" value="[ISO 2-character code for new country]">
<input type="hidden" name="shipping_state" value="[ISO 2-character code for new state]">
<input type="hidden" name="groupid" value="[numeric groupID]">
/* End optional fields */
<input type="submit" value="SUBMIT">
</form>
All POSTs attempting to use the single sign-on API must contain a FORM field "hash":
The “hash” field is the SHA256 hash of the concatenation of the API Key, username, and unix time fields.
Here is an example of a hash calculation for the case where:
API Key: 1234567890abcde
user: myuser
unixtime: 1506450751
hash = sha256("1234567890abcdemyuser1506450751")