Submit an Idea or a tool Contact Us
CafePress Developers Network
Home Tools

Content API - Authentication

Back to Content API Overview

Content APIs are available only on request and acceptance by CafePress.com. To request an API key please fax a signed Alpha Content API Agreement along with your PID, and a brief outline of what you want to do with the APIs at 650 655 3008 (Attention: Manisha).

Authentication APIs are used to authenticate with the CafePress platform. There are 3 different ways to authenticate as you will learn below.
a). Authenticate to your Account (you know the login and the password) - getUserToken(). A UserToken is generated dynamically and is associated with the authenticated member Account.
b). Enable your tool user to authenticate to their Account - getLoginToken(). A UserToken will be generated for their Account. Pass that user token everytime you make an API call in order to access their account.
c). Login as a guest to Create & Buy a Custom Product.

A User Token remains valid for 20 minutes of inactivity (subject to change) and then afterwards calls using that User Token will receive a ErrorAuthenticationExpiration error. User Tokens for anonymous users, however, last indefinitely.

authentication.getUserToken.cp

This is used for a non-interactive login procedure. You can use this if your tool uploads all images to one predefined account. The User Token retrieved as a response for this call should then be passed for most consecutive calls.
Signature
authentication.authentication.getUserToken.cp?appKey=xxx&username=xxx&password=xxx
Parameters
Required :  
appKey - An application key.
email - Login id for Cafepress website. 
password - The Password for this account       
Response
<?xml version="1.0" ?>
<value>85318ed0-8495-4790-b40c-49a85425820e</value>
Errors
Standard Errors as described here
Example
http://api.cafepress.com/authentication.getUserToken.cp?appkey=11111111-1111-1111&email=demo@cafepress.com&password=cafe

authentication.getLoginToken.cp

This is the interactive method used by your tool users to authenticate to "their account". It returns a "Login Token". This call is then followed by a redirect to the CafePress login page. When redirected to the login page 3 parameters are to be passed - appKey, loginToken, and goto. "goto" indicates what URL to return to after the user logs in. If login is successful a "User Token" will be appended to the goto URL.That User Token should be passed with every consecutive API call.
Signature
authentication.getLoginToken?appKey=xxx
Parameters
appKey - an application key. (Required)    	   
Response
<?xml version="1.0" ?>
<value>85318ed0-8495-4790-b40c-49a85425820e</value>
Errors
Error Authentication as described here
Example Call
http://api.cafepress.com/authentication.getLoginToken.cp?appKey=11111111-1111-1111-1111-111111111111
This call will return a Login Token. e.g. 8c626a50-3f6b-483e-b8bb-c8ca3fbd58f8

Now we need to redirect to the login page at cafepress to authenticate the user. Assume that after authentication we want to redirect to Cafepressdn.com, the call will look like
http://www.cafepress.com/cp/members/login.aspx?loginToken=8c626a50-3f6b-483e-b8bb-c8ca3fbd58f8&goto=http://cafepressdn.com?appKey=11111111-1111-1111

A userToken would be passed in the querystring when the goto URL is redirected to. Pass this User Token for all consecutive API calls.

authentication.getAnonymousUserToken.cp

This method fetches a User Token for a Guest (Anonymous) User who is only interested in creating and buying Custom Products. Pass this User Token for all consecutive API calls. User Tokens for anonymous users last indefinitely.
Signature
authentication.getAnonymousUserToken.cp?appKey=string-value
Parameters
Required:    
appKey - an application key.   	 
Response
A User Token is returned back.
<?xml version="1.0" ?>
<value>85318ed0-8495-4790-b40c-49a85425820e</value>
Errors
Error Authentication as described here
Example Call
http://api.cafepress.com/authentication.getAnonymousUserToken.cp?appKey=11111111-1111-1111-1111-111111111111

authentication.transferAnonymousUser.cp

Sometimes a user wants to start designing as a guest(anonymous) user and later decides to save the newly created designs and products in their account at CafePress. This method allows you to move the anonymous user data (designs and products) into the authenticated user's account. All media and products of the anonymous user are moved to the authenticated user, and the anonymous user is disabled.
Signature
authentication.getAnonymousUserToken.cp?appKey=string-value&userToken=string-value&
	anonymousUserToken=string-value
Parameters
Required:    
appKey - an application key.   	 
userToken - a valid user authentication token.
anonymousUserToken - the token for the anonymous user account that needs to be merged with the
Response
A list of Products that were transferred to the authenticated account from the anonymous user account.
Errors
Error Authentication as described here
Example Call
http://api.cafepress.com/authentication.getAnonymousUserToken.cp?appKey=11111111-1111-1111-1111-111111111111&userToken=8c626a50-3f6b-483e-b8bb-c8ca3fbd58f8&anonymousUserToken=85318ed0-8495-4790-b40c-49a85425820e
Signup to receive updates