Javascript User Profile API Examples

The JavaScript User Profile API allows users to perform authentication, authentication validation as well as some basic profile related functions all through JavaScript. This allows developers to perform login functions without having to post back a page.


This method will return the authentication Cookie name that automatically stores the authentication token when the Authenticate method is called.
var cookieName = Agility.UGC.API.GetAuthCookieName();
This method lets you set a custom Cookie name to store the authentication token into when the Authenticate method is called.
var cookieName = Agility.UGC.API.SetAuthCookieName("MyAuthCookieName");
This method will clear your current authentication cookie that the user is currently logged in as. You must pass the websiteUserTypeName in case there are multiple authentication points (User Types) within your system.
Agility.UGC.API.Authenticate(websiteUserTypeName, login, password, persistCookie, callback)
This method is used to authenticate a user against a specific website user type within the UGC system. An authentication token will be generated if successful and will set the authentication cookie defined by Agility.UGC.API.GetAuthCookieName();
Agility.UGC.API.Authenticate("Profile", "Username", "Password", true, function(data){
   if(data.ResponseType == Agility.UGC.API.ResponseType.OK){
         alert("Login Successful! Your Authentication Token is: " + data.ResponseData);
Agility.UGC.API.IsAuthenticated(websiteUserTypeName, callback)
This method will return a fully qualified Authentication Object which can be used to re-initialize the UGC API with the users unique profile ID and hash code. This is important as updates to profile related data can only be done if authenticated as an Administrator or the user who owns the profile record.
Agility.UGC.API.IsAuthenticated("Profile", function(data){
 if(data.ResponseType == Agiltity.UGC.API.ResponseType.OK){
   //User is authenticated.. and API access data has been refreshed to use the currently logged in users credentials.
Agility.UGC.API.ChangePassword(currentPassword, newPassword, callback)
This method is used to change a users password. A user must be properly authenticated for this to work.
var currentPassword = "myCurrentPass";
var newPassword = "myNewPass";

Agility.UGC.API.IsAuthenticated("Profile", function(data){
  if(data.ResponseType == Agility.UGC.API.ResponseType.OK){
        Agility.UGC.API.ChangePassword(currentPassword, newPassword, function(cpData){
              if(cpData.ResponseType == Agility.UGC.API.ResponseType.OK){
                      alert("Your password has been updated.");
Agility.UGC.API.RetrievePassword(websiteUserTypeName, login, callback)
This method will send an email to the user to retrieve their password.
Agility.UGC.API.RetrievePassword("Profile", "MyLoginName", function(data){
  if(data.ResponseType == Agility.UGC.API.ResponseType.OK){
      alert("Your password has been sent to your email");


Log in with your Agility username and password or
register for the site

Log In