L'app riceve quindi un insieme predefinito di variabili del modello all'interno di un parametro
state. Le informazioni state
predefinite per un nuovo URL sono:
FOLDER_RESOURCE_KEY: la chiave della risorsa della cartella principale.
USER_ID: l'ID profilo che identifica in modo univoco l'utente.
L'app deve eseguire questa richiesta seguendo questi passaggi:
Verifica che il campo action abbia un valore create.
Utilizza il valore userId per creare una nuova sessione per l'utente. Per ulteriori informazioni sugli utenti che hanno eseguito l'accesso, consulta Utenti e nuovi eventi.
Utilizza il metodo files.create per creare una risorsa file. Se nella richiesta è stato impostato folderId, imposta il campo parents sul valore folderId.
Il parametro state è codificato tramite URL, pertanto l'app deve gestire i caratteri di sfuggita e analizzarlo come JSON.
Utenti e nuovi eventi
Le app di Drive devono trattare tutti gli eventi "create" come potenziali accessi. Alcuni utenti potrebbero avere più account, pertanto l'ID utente nel parametro state
potrebbe non corrispondere alla sessione corrente. Se l'ID utente nel parametro state
non corrisponde alla sessione corrente, termina la sessione corrente per la tua
app e accedi come utente richiesto.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-02-24 UTC."],[[["When a user creates a new file with your app from Drive UI, your app receives a `state` parameter containing action, folder details, and user ID."],["Your app should verify the `action` is \"create\", create a user session, and use the provided information to create a new file via the Drive API."],["All \"create\" events should be treated as potential sign-ins and handled to accommodate users with multiple accounts, potentially requiring session switching."],["The `state` parameter is URL-encoded and needs to be parsed as JSON by your application for proper data extraction."]]],["When a user selects an app via Drive UI's \"New\" button, Drive redirects to the app's New URL, sending a `state` parameter. The `state` includes `action` (set to \"create\"), `folderId`, `folderResourceKey`, and `userId`. The app must verify the `action`, initiate a new user session based on `userId`, use `files.create` to generate a file resource, and handle `folderId` and `folderResourceKey`. All \"create\" events should be treated as potential sign-ins, with user sessions adjusted accordingly. The `state` parameter is URL-encoded JSON and must be parsed.\n"]]