Arborescence des pages

L'authentification par token est indispensable pour éviter les problèmes de rate limit intégrés à Rocket.Chat. À partir d'un compte créé dans Rocket.Chat, voici les commandes à lancer pour obtenir un userid + authToken  nécessaires pour l'authentification du plugin :

  • Pour récupérer le userid et le authtoken à partir d'un login/mdp
#Il faut récupérer les userid et authtoken avec la commande curl suivante
[me@home:~]$ curl https://chat.univ.fr/api/v1/login -d "username=superadmin&password=supermotdepasse" | cut -d\" -f7-14

:{"userId":"qtX4dyGe58TLbadf1","authToken":"7q3XT5dfe4ervxDiDRn0hJ-WDGRWlWGwCw-srWUE6Xsa
  • Ensuite il faut générer le personnal access token
[me@home:~]$ curl -H "X-Auth-Token: 7q3XT5dfe4ervxDiDRn0hJ-WDGRWlWGwCw-srWUE6Xsa" -H "X-User-Id: qtX4dyGe58TLbadf1" -H "Content-type:application/json" https://chat.univ.fr/api/v1/users.generatePersonalAccessToken -d '{"tokenName": "moodletoken"}'

{"token":"Wd8j4iWpA8TxVjkEMe8DopP1jILmQwQMjZ67ymQ12cB","success":true}
  • On peut ensuite lister les tokens, pour vérification
[me@home:~]$ curl -H "X-Auth-Token: 7q3XT5dfe4ervxDiDRn0hJ-WDGRWlWGwCw-srWUE6Xsa" -H "X-User-Id: qtX4dyGe58TLbadf1" -H t-type:application/json" https://chat.univ.fr/api/v1/users.getPersonalAccessTokens

{"tokens":[{"name":"moodletoken","createdAt":"2021-02-09T10:35:38.564Z","lastTokenPart":"mQ12cB"}],"success":true}
  • Pour recréer un token (en cas de perte)
[me@home:~]$ curl -H "X-Auth-Token: 7q3XT5dfe4ervxDiDRn0hJ-WDGRWlWGwCw-srWUE6Xsa" -H "X-User-Id: qtX4dyGe58TLbadf1" -H "Content-type:application/json" https://chat.univ.fr/api/v1/users.regeneratePersonalAccessToken -d '{"tokenName": "moodletoken"}'

{"token":"wH9Uq4ZzSmN36qWcZ89pouetRofPJt5w_zBSuGqE_KK","success":true}


  • Aucune étiquette