Authentification

Print Portal peut être configuré avec ou sans obligation d’authentification. Lorsque l’authentification est activée, avant de pouvoir accéder aux ressources de Print Portal, une requête doit provenir d’un utilisateur authentifié.

La procédure suivante explique comment envoyer la requête d’authentification. Lorsque l’authentification Print Portal est activée et que le nom d’utilisateur et le mot de passe adéquats sont introduits, une réponse de réussite est renvoyée et comprend le jeton d’authentification à utiliser pour les prochains appels d’API REST.

FerméPour envoyer une requête d’authentification

  1. Ouvrez l’interface utilisateur Swagger de Print Portal. Pour cela, ajouter « /swagger/ » à l’URL de Print Portal, comme suit :

    http://localhost/BarTender/swagger/

  2. Cliquez sur Publier pour l’élément supérieur, Authentification, pour afficher les exigences d’authentification de la requête.

  3. Cliquez sur Essayer.

  4. Ajouter votre nom d'utilisateur et votre mot de passe.

  5. Cliquez sur Exécuter.

FerméExemple JavaScript

Copier
/*---------------------------------------------------------------------------------------------
Authenticate */

// This will allow the user to extract an authentication token

// Change the two variables to your credentials
let username = "domain\\username";
let password = "password";

// Change these to the URL
let basePrintPortalURL = "https://example.com/Bartender/";

// First step, authentication
fetch(basePrintPortalURL + 'Authenticate', {
  method: 'post',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
            "username": username,
            "password": password
  })
               })
//The response will be a JSON object which contains a token and expiration
.then(response => response.json())

.then(result => {
  console.log('Success:', result);
  //If successful, a token will be returned as the result
  // Token will be used on the header of print call using the header 'Authorization': 'Bearer ' + token
})
.catch(error => {
  console.error("The user name or password provided is incorrect.");
});