Crea un utente

Se viene assegnato il ruolo di amministratore per una risorsa, puoi creare un utente con accesso a quella risorsa o a quelli al suo interno.

Gli utenti vengono creati tramite il metodo user.create.

L'indirizzo email di un nuovo utente deve avere un Account Google corrispondente, che può essere creato per un indirizzo email esistente. La risorsa utente creata deve includere anche almeno un ruolo utente assegnato.

Ecco un esempio di come creare un nuovo utente con accesso standard a un inserzionista:

Java

// Create the user structure.
User user = new User();
user.setEmail(email-address);
user.setDisplayName(display-name);

// Create the assigned user role structure.
AssignedUserRole assignedUserRole = new AssignedUserRole();
assignedUserRole.setAdvertiserId(advertiser-id);
assignedUserRole.setUserRole("STANDARD");

// Add assigned user role list to the user.
user.setAssignedUserRoles(ImmutableList.of(assignedUserRole));

// Configure the create request.
Users.Create request = service.users().create(user);

// Create the user.
User response = request.execute();

// Display the user.
System.out.printf("User %s was created with email %s.",
    response.getName(),
    response.getEmail());

Python

# Create a user object.
user_obj = {
    'email': email-address,
    'displayName': display-name,
    'assignedUserRoles': [
        {
            'advertiserId': advertiser-id,
            'userRole': 'STANDARD'
        }
    ]
}

# Build request.
request = service.users().create(
    body=user_obj
)

# Execute request.
response = request.execute()

# Display the new user.
print('User %s was created with email %s.'
      % (response['name'], response['email']))

PHP

// Create the user structure.
$user = new Google_Service_DisplayVideo_User();
$user->setEmail(email-address);
$user->setDisplayName(display-name);

// Create the assigned user role structure.
$assignedUserRole = new Google_Service_DisplayVideo_AssignedUserRole();
$assignedUserRole->setAdvertiserId(advertiser-id);
$assignedUserRole->setUserRole('STANDARD');

// Add assigned user role list to the user.
$user->setAssignedUserRoles(array($assignedUserRole));

// Call the API, creating the user with the assigned user role.
$result = $this->service->users->create($user);

// Display the user.
printf(
    'User %s was created with email %s.\n',
    $result['name'],
    $result['email']
);