API PHP code
Question asked by Alex Johnson - 6/22/2019 at 6:51 AM
Unanswered
Hi

According to this page "https://mail.smartertools.com/Documentation/api#/reference/SmarterMail.Web.Controllers.Api.AuthenticationController/RetrieveLoginToken" we can create an auto-login token for any given user (email account) on the system if we generate the token with system admin credentials.

Could someone please share the PHP code for such action?
Alex Johnson Replied
I've created a php code for temporary-password-generation but the following error has accord:

[2019.06.22] [CurrentUser: SYSTEM]
[2019.06.22] [6/22/2019 8:45:22 PM]
[2019.06.22] http://127.0.0.1/api/v1/auth/generate-temp-pass
[2019.06.22] Application Error. Message: The controller for path '/api/v1/auth/generate-temp-pass' was not found or does not implement IController., Stack Trace:    at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
[2019.06.22]    at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
[2019.06.22]    at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
[2019.06.22]    at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
[2019.06.22]    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
[2019.06.22]    at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
[2019.06.22]    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Smartermail build 7090
Installed on localhost as a free version for test and is accessible at http://127.0.0.1
Sébastien Riccio Replied
Looks like you're missing an information in the target URL

From the API docs:

var url = SmarterMailUrl + "api/v1/auth/generate-temp-pass/" + input_email + ""; 

So I guess it should be something like api/v1/auth/generate-temp-pass/user@domain.tld

Not tested, I did not use this call (yet)


Sébastien Riccio System & Network Admin https://swisscenter.com
Sébastien Riccio Replied
I tested it from Katalon Studio, it works, but you need first to impersonate as the domain administrator for domain.tld using api/v1/settings/sysadmin/manage-domain.

So,

Step 1/ Login as system admin account and get auth token
Step 2/ Get new token to manage specific domain api/v1//settings/sysadmin/manage-domain/domain.tld
Step 3/ Call generate-temp-pass api/v1/auth/generate-temp-pass/user@domain.tld 

Result:
{
  "tempPassword":"LUr3vf}TGZ$t=a4",
  "tempPasswordExpUtc":"2019-06-23T20:55:33.7854325Z",
  "success":true,
  "resultCode":200,
  "message":""
}



Sébastien Riccio System & Network Admin https://swisscenter.com

Reply to Thread

Enter the verification text