Passa al contenuto principale
Versione: 2025.003.000 (beta)

Come fare per

Ottenere il token personale

Come abilitare il sistema all'uso delle API

Un prerequisito per il processo è che la partita IVA associata al sistema abbia la licenza che abilita l'uso delle API.


warning

L'abilitazione dell'ambiente è consentita SOLO ai System Integrator Certificati. Per avere dettagli sul percorso di certificazione clicca qui


È necessario aprire un ticket su MySupport nella coda dedicata:

  • Linea di prodotto: TS Enterprise Cloud
  • Procedura: TS Enterprise Cloud
  • Area: WebAPI e Personalizzazioni
  • Modulo: Supporto sviluppo WebAPI

Mysupport


Mysupport


specificando:

  • l'URL dell'installazione di Teamsystem Enterprise Cloud che si desidera abilitare
  • un indirizzo email della risorsa certificata

Al termine del processo di abilitazione, verrà distribuita una chiave tecnica che consentirà l'accesso ai servizi e verrà specificato il nome dell'ambiente da utilizzare nell'ambito.


Esempio di risposta di supporto dopo il processo di abilitazione:

ParametroValore
cidwebapixxxx1
apigwt_base_urlhttps://apixxxx1.teamsystem.io
scopewebapixxxx1_alywebapixxxx1
api_keyeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9IsInR5cCI6IkpXVCJ9IsInR5cCI6IkpXVCJ9IsInR5cCI6IkpXVCJ9.......
usernameadmin_webapixxxx1

suggerimento

Il codice di licenza che abilita l'uso delle API è 4520.


MODULOCODICELICENZADESCRIZIONE
4520TE-45204520Web API
55166S-TE-551664520Web API
84006SAAS-TE-840064520Web API
80057SAAS-TE-800574520Web API

N.B.: La differenza tra i vari codici è legata alla presenza di diversi listini per singole procedure e/o diverse installazioni.

TSE utilizza un token JWT per autenticare i servizi applicativi Non criptato firmato con chiave asimmetrica (pubblica/privata) Lo scope consente di controllare l’ambito di applicabilità del token e coincide con l’ambiente applicativo di lavoro su cui si può operare e fa parte del payload.  Il token scade ed è valido per 8 ore (exp - expiration time) L’api key è per SI/Impianto Cliente

Utilizzare il token di sessione (chiave API)

Ora puoi iniziare a utilizzare la chiave API per autenticare le tue richieste. Puoi usare la chiave API nell'intestazione della tua richiesta come Bearer Token:

warning

È importante che nella sezione del token la chiave API sia preceduta dalla parola "Bearer" seguita da uno spazio, ad esempio:

{
"token": "Bearer AbCdyJhbGciOiJ1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ3ZWJhcGlhZG1pbiIsIndlYmFwaTphdXRoZW50aWNhdGlvbjpzY29wZSI6Imh1Yl9hZG1pbixjc2RlbW9fYWx5Y3NkZW1vIiwianRpIjoiNTRlOTJlY2MtN2I1OS00YWVjLThiOTMtYWVjYmQwNTk1ZmUzIiwiaWF0IjoxNjk0MDkwMzc5LCJpc3MiOiJBbHlDRVNydjJTcnZJc3N1ZXIiLCJhdWQiOiJBbHlDRVNydjJTcnZBdWRpZW5jZSJ9.QyQdBWnULnM9TF1eCuY7x8JIXxPuOUiyg1_YnxbjaCE"
}
Editor dal vivo
function get_token(props) {
  ///Modifica i seguenti valori ricevuti durante l'attivazione
  const APIGWT_BASE_URL = "https://apicsdemo.teamsystem.io";
  const SCOPE = "csdemo_alycsdemo";
  const APIKEY = "XyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ3ZWJhcGlhZG1pbiIsIndlYmFwaTphdXRoZW50aWNhdGlvbjpzY29wZSI6Imh1Yl9hZG1pbixjc2RlbW9fYWx5Y3NkZW1vIiwianRpIjoiNTRlOTJlY2MtN2I1OS00YWVjLThiOTMtYWVjYmQwNTk1ZmUzIiwiaWF0IjoxNjk0MDkwMzc5LCJpc3MiOiJBbHlDRVNydjJTcnZJc3N1ZXIiLCJhdWQiOiJBbHlDRVNydjJTcnZBdWRpZW5jZSJ9.QyQdBWnULnM9TF1eCuY7x8JIXxPuOUiyg1_YnxbjaCE"
  const USERNAME = "admin_csdemo";

  const GRANT_TYPE = "token";
  const PASSWORD = "";
  const BEARER_TOKEN = "Bearer " + APIKEY;
  const ALLOW_ORIGIN = "http://localhost:3000";
  const CONTENT_TYPE = "application/x-www-form-urlencoded";
  const WEBURL = APIGWT_BASE_URL + "/api/v1/auth/token";
  const [token, setToken] = useState(null);
  const [result, setResult] = useState('');
  const [error, setError] = useState('');

  const myHeaders = new Headers();
  myHeaders.append("Content-Type", CONTENT_TYPE);
  myHeaders.append("Access-Control-Allow-Origin", ALLOW_ORIGIN);

  const urlencoded = new URLSearchParams();
  urlencoded.append("username", USERNAME);
  urlencoded.append("grant_type", GRANT_TYPE);
  urlencoded.append("scope", SCOPE);
  urlencoded.append("token", BEARER_TOKEN);
  urlencoded.append("password", PASSWORD);

  const requestOptions = {
    method: "POST",
    headers: myHeaders,
    body: urlencoded,
    redirect: "follow"
  };

  const authenticate = async () => {
    fetch(WEBURL, requestOptions)
      .then((response) => response.text())
      .then(result => setResult(result))
      .catch(error => setError(error.toString()));
  };

  const handleAuthResponse = () => {
    const hash = window.location.hash;
    if (hash) {
      const params = new URLSearchParams(hash.substring(1));
      const accessToken = params.get('access_token');
      if (accessToken) {
        setToken(accessToken);
      }
    }
  };

  useEffect(() => {
    handleAuthResponse();
  }, []);

  return (
    <div>
      <button onClick={authenticate}>Ottieni Token</button>
      <div>
        <code className="language-json" style={{ whiteSpace: 'pre-wrap' }}>

          {(() => {
            try {
              return JSON.stringify(JSON.parse(result), null, 2);
            } catch (e) {
              return result;
            }
          })()}
        </code>
      </div>
      <div>
        <pre>
          {(() => {
            try {
              return JSON.stringify(JSON.parse(error), null, 2);
            } catch (e) {
              return error;
            }
          })()}
        </pre>
      </div>
    </div>
  );
}
Risultato
Loading...