/Account/QuickLogin
Allows the client to authenticate itself with the API using a Quick-Login. performed in the current HTTP Session. This method is an alternative to the Login and WwwLogin resources.
Note: To be able to access the current session, cookies must be enabled.
Note 2: Community Login is demonstrated in the link above, as it uses Quick-Login in session mode. API documentation for Quick-Login can be found here: QuickLogin API Documentation. You need to have the Community Package installed for the Community Login to be available.
Note 3: It is assumed the Agent API account resides on the same broker. The Agent API is an HTTP REST API for using an XMPP account on an XMPP broker. Once you have made a Quick-Login in a broker, you can use the RemoteQuickLogin
resource to perform session logins on other brokers using the QuickLogin on the current broker, providing the JWT token obtained from the current broker.
If authentication succeeds, a JSON Web Token (or JWT) is returned to the client. This token can be used as a Bearer token in subsequent calls to the API. It needs to be refreshed before it expires.
JSON
- Request
{ "seconds":Required(Int(0 < PSeconds <= 3600)) }
- Response (if successful)
{ "jwt":Required(Str(PJwt)), "userName":Required(Str(PUserName)), "expires":Required(DateTime(PExpires)) }
XML
- Request
<QuickLogin xmlns="https://waher.se/Schema/BrokerAgent.xsd" seconds=(Required(Int(0 < PSeconds <= 3600))) />
- Response (if successful)
<LoggedIn xmlns="https://waher.se/Schema/BrokerAgent.xsd" jwt=(Required(Str(PJwt))) userName=(Required(Str(PUserName))) expires=(Required(DateTime(PExpires))) />
Input Parameters
Parameter | Description |
---|---|
PSeconds |
Requested number of seconds before the JWT token that will be issued expires. |
Response Parameters
Parameter | Description |
---|---|
PJwt |
A token representing the login to the account. This token is seant as a Bearer token in requests requiring authentication. |
PUserName |
The user name of the account used for the Quick-Login. |
PExpires |
When the JWT token expires. The token needs to be renewed before this token expires, if the client wishes to maintain the connection. After the token expires, the client needs to login again. |
Javascript Library
Use the following asynchronous method in the Javascript Library, to call this resource.
var Response = await AgentAPI.Account.QuickLogin(Seconds);
Note: If login to the account is successful, the API library will maintain the resulting token, and make sure to refresh it regularly.