External sign-in API
9 min
Criado por Knowledge Engineering Team em 11/03/2021 14:58
Atualizado por Agente Zenvia - Jean em 09/08/2024 15:53

On this page

External sign-in concepts and usage

Create a temporary access token

Access Movidesk using a temporary access token

Sign in to Movidesk from an external application

 

 

External sign-in concepts and usage

Movidesk offers two different APIs for external sign-in to provide you with additional flexibility when integrating Movidesk into your application:

  • Temporary access token API
  • External sign-in API

You can also use the Temporary access token API to provide temporary access to users on an ad-hoc basis. For this purpose, we recommend using tools such as Postman to send the API request and generate the token.

 

Create a temporary access token

Use this API endpoint to create a temporary access token, which can be used to access Movidesk without entering user credentials.

When using the access token, the user will be signed in with a specific user account based on the API request. The signed-in user will have the system permissions of that user account’s access profile.

Clipboard
NOTE

The access token will expire 15 minutes after it is created. After using the token, the user will remained signed in until they sign out, or until their session times out due to inactivity. You can configure session timeout settings on the Environment tab in Configuration > Parameters.

 

The primary use cases for this API are the following:

  1. To provide access to private articles in the knowledge base. This is usually done by using a generic user account with the necessary permissions and access.

To integrate your application with Movidesk and access Movidesk without requiring a password. In this scenario each user generally needs a unique user account in Movidesk mapped to their user credentials in your application.

POST: https://api.movidesk.com/public/v1/login/generateToken

 

Parameters

Location

Type

Required?

Description

token

Query string

String

Yes

Movidesk API token found in Configurations > Account > Parameters

username

Query string

String

Yes

Username of a Movidesk user account.

When accessing Movidesk using a temporary access token, the user will be signed in with the user account associated with this username.

Note that the username must be URL encoded.

 

The example below is a request to generate a temporary access token for the user account with the username “jsmith”. Anyone accessing Movidesk with the temporary access token generated by this request will be signed in as “jsmith”.

The response contains JSON data with the temporary access token and the token’s expiration date in the UTC timezone.

Sample request

GET: https://api.movidesk.com/public/v1/login/generateToken?token=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&username=jsmith

Sample response

{
    "token": "0oekfQx9ynuj9ooPmxz9qY",
    "expirationDate": "2020-03-09T20:11:36.58705Z"
}

 

Access Movidesk using a temporary access token

Use this API endpoint to access Movidesk using the temporary access token returned by the  previous endpoint.

A successful request to this endpoint returns an authentication cookie (ASPXAUTH) and a 302 status code to redirect to the yourcompany.movidesk.com domain. After being redirected the user will be signed in automatically with the authentication cookie, bypassing the sign-in screen.

GET: https://yourcompany.movidesk.com/ExternalLoginToken/AccessUrl

 

Clipboard
NOTE

Replace “yourcompany” with your Movidesk subdomain in the URL above.

 

Parameters

Location

Type

Required?

Description

loginToken

Query string

String

Yes

Temporary access token obtained via the /login/generateToken endpoint.

Note that this is not your Movidesk API token.

url

Query string

URL

Yes

Your Movidesk URL that you want to access with the temporary access token.

For example, this could be the URL for your Movidesk customer portal, or the URL for an article in your Movidesk knowledge base.

 

 

This sample request should be entered as the URL in a web browser in order to access the URL specified in the url parameter.

The user will be automatically signed in—with the user account specified in the API request that generated the token—and then redirected to the specified URL.

Sample request

GET: https://yourcompany.movidesk.com/ExternalLoginToken/AccessUrl?loginToken=XXXXXXXXXXXXXXXXXXXXXX&url=https://yourcompany.movidesk.com

Clipboard
NOTE

Replace “yourcompany” with your Movidesk subdomain in the URL above.

 

Head with gears
TIP

Do not include “GET:” when entering the request into a web browser, as it is the default HTTP method used by web browsers. For example, you should only enter the following in your web browser (after making the appropriate substitutions of the bolded elements):

https://yourcompany.movidesk.com/ExternalLoginToken/AccessUrl?loginToken=XXXXXXXXXXXXXXXXXXXXXX&url=https://yourcompany.movidesk.com

 

Sign in to Movidesk from an external application

Use this API endpoint to integrate Movidesk into your application. You can display form fields to your users and prompt them to enter their username and password, or use back-end mapping to provide a single sign-on experience.

You can use this in conjunction with our People API to keep Movidesk user records synchronized with the user records in your application.

POST: https://yourcompany.movidesk.com/Account/Authenticate

 

Clipboard
NOTE

Replace “yourcompany” with your Movidesk subdomain in the URL above.

 

Parameters

Location

Type

Required?

Description

Content-Type

Header

Content type

Yes*

If sending the other parameters as part of the query string, this can be left blank.

If sending the other parameters as form data in the Body, this should always be:

application/x-www-form-urlencoded

token

Query string or Body

String

Yes

Movidesk API token found in Configurations > Account > Parameters

username

Query string or Body

String

Yes

Username of the Movidesk user account.

Note that the username must be URL encoded.

password

Query string or Body

String

Yes

Password of the Movidesk user account.

Note that the password must be URL encoded.

 

Head with gears
TIP

This endpoint is flexible and will accept the various parameters listed above as part of the query string in the URL, or sent as part of the request body as form data.

 

One of the examples below includes the necessary request parameters in the query string, while the other submits the parameters as form data in the request body. The requests include the username “jsmith” and the password “examplepassword123” to authenticate the user.

The response will return an authentication cookie (ASPXAUTH) and a 302 status to redirect to your Movidesk customer portal. The user will be signed in automatically due to the authentication cookie.

Sample request using query string parameters

POST: https://yourcompany.movidesk.com/Account/Authenticate?token=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&username=jsmith&password=examplepassword123

 

Sample using an HTML form

<form action=" https://yourcompany.movidesk.com/Account/Authenticate" target="_blank" method="post">
 <input type="hidden" name="Token" value="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" />
 <input type="hidden" name="username" value="jsmith" />
 <input type="hidden" name="password" value="examplepassword123" />
 <button type="submit" class="btn btn-primary">Sign in</button>
</form>

 

Warning
WARNING

We do not recommend adding the form above to the HTML code of a webpage, as it would expose the API Token to the web browser and constitute a security risk.

 

Classifique este artigo
Últimos artigos visitados