Token con accesso limitato
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
I token di accesso a uso limitato forniscono protezione dagli spoofing delle richieste e dagli attacchi di riproduzione, garantendo che l'azione venga eseguita dall'utente a cui è stato inviato il messaggio. La protezione si ottiene aggiungendo un parametro token univoco ai parametri della richiesta e verificandolo quando viene richiamata l'azione.
Il parametro token deve essere generato come chiave che può essere utilizzata solo per una determinata azione e un utente specifico. Prima che venga eseguita l'azione richiesta, devi verificare che il token sia valido e che corrisponda a quello generato per l'utente. Se il token corrisponde, è possibile eseguire l'azione e il token non è più valido per le richieste future.
I token di accesso devono essere inviati all'utente come parte della proprietà url
di HttpActionHandler. Ad esempio, se la tua applicazione gestisce le richieste di approvazione a http://www.example.com/approve?requestId=123
, dovresti includere un parametro accessToken
aggiuntivo e ascoltare le richieste inviate a http://www.example.com/approve?requestId=123&accessToken=xyz
.
La combinazione requestId=123
e accessToken=xyz
deve essere generata in anticipo, assicurandoti che non sia possibile dedurre accessToken
da requestId
. Qualsiasi richiesta di approvazione con requestId=123
e senza accessToken
o con accessToken
non uguale a xyz
deve essere rifiutata. Quando questa richiesta sarà soddisfatta, ogni richiesta futura con lo stesso ID e token di accesso dovrà essere rifiutata.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-25 UTC.
[null,null,["Ultimo aggiornamento 2025-07-25 UTC."],[],[],null,["# Limited Use Access Tokens\n\nLimited-Use Access Tokens provide protection from request spoofing and [replay attacks](http://en.wikipedia.org/wiki/Replay_attack), ensuring that the action is performed by the user the message was sent to. Protection is achieved by adding a unique token parameter to the request parameters and verifying it when the action is invoked.\n\nThe token parameter should be generated as a key that can only be used for a specific action and a specific user. Before the requested action is performed, you should check that the token is valid and matches the one you generated for the user. If the token matches then the action can be performed and the token becomes invalid for future requests.\n\nAccess tokens should be sent to the user as part of the `url` property of the [HttpActionHandler](/workspace/gmail/markup/reference/types/HttpActionHandler). For instance, if your application handles approval requests at `http://www.example.com/approve?requestId=123`, you should consider including an additional `accessToken` parameter to it and listen to requests sent to `http://www.example.com/approve?requestId=123&accessToken=xyz`.\n\nThe combination `requestId=123` and `accessToken=xyz` is the one that you have to generate in advance, making sure that the `accessToken` cannot be deduced from the `requestId`. Any approval request with `requestId=123` and no `accessToken` or with a `accessToken` not equal to `xyz` should be rejected. Once this request gets through, any future request with the same id and access token should be rejected too."]]