Send Docs Feedback

Note: Most user interface tasks can be performed in Edge Classic or the New Edge experience. For an overview, getting started topics, and release notes specific to the New Edge experience, see the docs.

Changing a user password

Changing a user's password

Request syntax

curl -X PUT https://<baas_host_name>/<org>/<app>/users/<username_or_email>/password -d '{oldpassword:<old_password>,newpassword:<new_password>}'

Parameters

Parameter Description
org Organization UUID or organization name
app Application UUID or application name
username_or_email Username or email of the user entity whose password you want to reset.
old_password

User entity's old password.

If your request is authenticated with an application-level token, this is not required. For more, see Application client authentication.

new_password User entity's new password.

Example request

curl -X PUT https://<baas_host_name>/my-org/my-app/users/john.doe/password -d '{"newpassword":"foo9876a","oldpassword":"bar1234b"}'

Example response

{
  "action": "set user password",
  "timestamp": 1355185897894,
  "duration": 47
}
		

SDK method

-(ApigeeClientResponse *)updateUserPassword:(NSString *)usernameOrEmail 
																oldPassword:(NSString *)oldPassword 
																newPassword:(NSString *)newPassword
		

Parameters

Parameter Description
usernameOrEmail Username or email of the user entity whose password you want to reset.
old_password

User entity's old password.

If your request is authenticated with an application-level token, this is can be nil. For more, see Application client authentication.

new_password User entity's new password.

Example request

//we recommend you call ApigeeClient from your AppDelegate.
//for more information see the iOS SDK install guide: http://apigee.com/docs/app-services/content/installing-apigee-sdk-ios
//create an instance of AppDelegate
AppDelegate *appDelegate = (AppDelegate *)[ [UIApplication sharedApplication] delegate];

//provide the username or email, old password, and new password of the user entity
//in a production app, you would likely get these from a form
NSString *username = @"someUser";
NSString *oldpassword = @"someOldPassword1";
NSString *newpassword = @"shineyNewPassword1";

//call updateUserPassword to initiate the PUT request to change the user's password
ApigeeClientResponse *response = [appDelegate.dataClient updateUserPassword:username oldPassword:oldpassword newPassword:newpassword];

@try {    
    //success
}
@catch (NSException * e) {
    //fail
}
		

Example response

{
  "action": "set user password",
  "timestamp": 1355185897894,
  "duration": 47
}
		

SDK method

changePasswordAsync(usernameOrEmail, oldPassword, newPassword, callback)

Parameters

Parameter Description
usernameOrEmail Username or email of the user entity whose password you want to reset.
old_password

User entity's old password.

If your request is authenticated with an application-level token, this is can be null. For more, see Application client authentication.

new_password User entity's new password.
callback An ApiResponseCallback instance to handle the async API response.

Example request

//create an instance of ApigeeClient to call API methods
ApigeeClient apigeeClient = new ApigeeClient(ORGNAME,APPNAME,this.getBaseContext());
ApigeeDataClient client = apigeeClient.getDataClient();

//the username or email, old password and new password of the user entity
//in production you would likely grab these from a form
String username = "someUser";
String oldPassword = "someOldPassword1";
String newPassword = "shinyNewPassword1";

//call changePasswordAsync to initiate the PUT request to change the user's password
client.changePasswordAsync(username, oldPassword, newPassword, new ApiResponseCallback() {
	@Override
	public void onException(Exception e) { 
		// Error		
	}
	
	@Override
	public void onResponse(ApiResponse response) {
	    try { 
	        if (response != null) {
	            // Success
	        }
	    } catch (Exception e) { //The API request returned an error
	        	// Fail
	    }
	}
});
		

Example response

{
  "action": "set user password",
  "timestamp": 1355185897894,
  "duration": 47
}
		

The example assumes use of the JavaScript (HTML5) SDK.

SDK method

Entity.changePassword(newPassword, oldPassword, callback)

Parameters

Parameter Description
oldPassword

User entity's old password.

If your request is authenticated with an application-level token, this is can be null. For more, see Application client authentication.

newPassword User entity's new password.
callback A callback function to handle the async API response.
var options = {
  method:'PUT',
  endpoint:'users/john.doe/password',
  body:{ 
  	oldpassword: 'myoldpassword',
  	newpassword:'foo9876a' 
  }
};
client.request(options, function (err, data) {
  if (err) {
      //error — PUT failed
  } else {
      //success — data will contain raw results from API call       
  }
});
		

The example assumes use of the Ruby SDK.

app = Usergrid::Application.new 'https://<baas_host_name>/my-org/my-app/'
john_doe = app['users/john.doe/password'].entity
john_doe.newpassword = 'foo9876a'
john_doe.save

The example assumes use of the Node.js module.

var options = {
    method:'PUT',
    endpoint:'users/john.doe/password',
    body:{ oldpassword:'mypassword', newpassword:'foo9876a' }
};
client.request(options, function (err, data) {
    if (err) {
        //error — PUT failed
    } else {
        //success — data will contain raw results from API call       
    }
});

 

Help or comments?