Manage client user activity

  • ClientUser state changes between ACTIVE and INACTIVE to control access to the Authorized Buyers Marketplace UI.

  • Deactivating a ClientUser temporarily revokes their access to the UI using the buyers.clients.users.deactivate method.

  • You cannot deactivate a ClientUser before they have accepted their invitation.

  • Reactivating a ClientUser restores their access to the UI using the buyers.clients.users.activate method.

You can use the following methods to change the state of a ClientUser .

state is set to ACTIVE for new ClientUser resources automatically after they accept an invitation. You can set state to INACTIVE for a given ClientUser to revoke the individual's access to the Authorized Buyers Marketplace UI.

Deactivate

You can deactivate a ClientUser with the buyers.clients.users.deactivate method.

For example, you can use deactivate to temporarily revoke an individual's access to the Authorized Buyers Marketplace UI for an individual under a given client, and might restore it in the future. To permanently revoke access, use buyers.clients.users.delete .

The following sample demonstrates how you can deactivate a ClientUser with the deactivate method.

REST

Request

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/clients/873721984/users/4573644:deactivate?alt=json
Authorization: Bearer ACCESS_TOKEN 
Content-Type: application/json

Response

{
 "name": "buyers/12345678/clients/873721984/users/4573644",
 "state": "INACTIVE",
 "email": "jessie@luxurymarscruises.mars"
}

Java

 /* 
 * Copyright 2022 Google LLC 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *    https://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */ 
 package 
  
 com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.clients.users 
 ; 
 import 
  
 com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace 
 ; 
 import 
  
 com.google.api.services.authorizedbuyersmarketplace.v1.model.ClientUser 
 ; 
 import 
  
 com.google.api.services.authorizedbuyersmarketplace.v1.model.DeactivateClientUserRequest 
 ; 
 import 
  
 com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils 
 ; 
 import 
  
 java.io.IOException 
 ; 
 import 
  
 java.security.GeneralSecurityException 
 ; 
 import 
  
 net.sourceforge.argparse4j.ArgumentParsers 
 ; 
 import 
  
 net.sourceforge.argparse4j.inf.ArgumentParser 
 ; 
 import 
  
 net.sourceforge.argparse4j.inf.ArgumentParserException 
 ; 
 import 
  
 net.sourceforge.argparse4j.inf.Namespace 
 ; 
 /** 
 * This sample illustrates how to deactivate a client user for the given buyer, client, and user ID. 
 * 
 * <p>Deactivating a client user allows one to temporarily remove a given client user from accessing 
 * the Authorized Buyers UI on behalf of a client. Access can be restored by calling 
 * buyers.clients.users.activate. 
 * 
 * <p>Note that a client user in the "INVITED" state can not be deactivated, and attempting to 
 * deactivate it will result in an error response. 
 */ 
 public 
  
 class 
 DeactivateClientUsers 
  
 { 
  
 public 
  
 static 
  
 void 
  
 execute 
 ( 
 AuthorizedBuyersMarketplace 
  
 marketplaceClient 
 , 
  
 Namespace 
  
 parsedArgs 
 ) 
  
 { 
  
 Long 
  
 accountId 
  
 = 
  
 parsedArgs 
 . 
 getLong 
 ( 
 "account_id" 
 ); 
  
 Long 
  
 clientId 
  
 = 
  
 parsedArgs 
 . 
 getLong 
 ( 
 "client_id" 
 ); 
  
 Long 
  
 clientUserId 
  
 = 
  
 parsedArgs 
 . 
 getLong 
 ( 
 "client_user_id" 
 ); 
  
 String 
  
 name 
  
 = 
  
 String 
 . 
 format 
 ( 
 "buyers/%d/clients/%d/users/%d" 
 , 
  
 accountId 
 , 
  
 clientId 
 , 
  
 clientUserId 
 ); 
  
 ClientUser 
  
 clientUser 
  
 = 
  
 null 
 ; 
  
 try 
  
 { 
  
 clientUser 
  
 = 
  
 marketplaceClient 
  
 . 
 buyers 
 () 
  
 . 
 clients 
 () 
  
 . 
 users 
 () 
  
 . 
 deactivate 
 ( 
 name 
 , 
  
 new 
  
 DeactivateClientUserRequest 
 ()) 
  
 . 
 execute 
 (); 
  
 } 
  
 catch 
  
 ( 
 IOException 
  
 ex 
 ) 
  
 { 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Marketplace API returned error response:%n%s" 
 , 
  
 ex 
 ); 
  
 System 
 . 
 exit 
 ( 
 1 
 ); 
  
 } 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Deactivated client user with name \"%s\":%n" 
 , 
  
 name 
 ); 
  
 Utils 
 . 
 printClientUser 
 ( 
 clientUser 
 ); 
  
 } 
  
 public 
  
 static 
  
 void 
  
 main 
 ( 
 String 
 [] 
  
 args 
 ) 
  
 { 
  
 ArgumentParser 
  
 parser 
  
 = 
  
 ArgumentParsers 
 . 
 newFor 
 ( 
 "DeactivateClientUsers" 
 ) 
  
 . 
 build 
 () 
  
 . 
 defaultHelp 
 ( 
 true 
 ) 
  
 . 
 description 
 (( 
 "Deactivate a client user with the given buyer, client, and user ID." 
 )); 
  
 parser 
  
 . 
 addArgument 
 ( 
 "-a" 
 , 
  
 "--account_id" 
 ) 
  
 . 
 help 
 ( 
  
 "The resource ID of the buyers resource under which the parent client was created. " 
  
 + 
  
 "This will be used to construct the name used as a path parameter for the " 
  
 + 
  
 "users.deactivate request." 
 ) 
  
 . 
 required 
 ( 
 true 
 ) 
  
 . 
 type 
 ( 
 Long 
 . 
 class 
 ); 
  
 parser 
  
 . 
 addArgument 
 ( 
 "-c" 
 , 
  
 "--client_id" 
 ) 
  
 . 
 help 
 ( 
  
 "The resource ID of the buyers.clients resource under which the client user was" 
  
 + 
  
 " created. This will be used to construct the name used as a path parameter for" 
  
 + 
  
 " the users.deactivate request." 
 ) 
  
 . 
 required 
 ( 
 true 
 ) 
  
 . 
 type 
 ( 
 Long 
 . 
 class 
 ); 
  
 parser 
  
 . 
 addArgument 
 ( 
 "-u" 
 , 
  
 "--client_user_id" 
 ) 
  
 . 
 help 
 ( 
  
 "The resource ID of the buyers.clients.users resource that is being deactivated. " 
  
 + 
  
 "This will be used to construct the name used as a path parameter for the " 
  
 + 
  
 "users.deactivate request." 
 ) 
  
 . 
 required 
 ( 
 true 
 ) 
  
 . 
 type 
 ( 
 Long 
 . 
 class 
 ); 
  
 Namespace 
  
 parsedArgs 
  
 = 
  
 null 
 ; 
  
 try 
  
 { 
  
 parsedArgs 
  
 = 
  
 parser 
 . 
 parseArgs 
 ( 
 args 
 ); 
  
 } 
  
 catch 
  
 ( 
 ArgumentParserException 
  
 ex 
 ) 
  
 { 
  
 parser 
 . 
 handleError 
 ( 
 ex 
 ); 
  
 System 
 . 
 exit 
 ( 
 1 
 ); 
  
 } 
  
 AuthorizedBuyersMarketplace 
  
 client 
  
 = 
  
 null 
 ; 
  
 try 
  
 { 
  
 client 
  
 = 
  
 Utils 
 . 
 getMarketplaceClient 
 (); 
  
 } 
  
 catch 
  
 ( 
 IOException 
  
 ex 
 ) 
  
 { 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Unable to create Marketplace API service:%n%s" 
 , 
  
 ex 
 ); 
  
 System 
 . 
 out 
 . 
 println 
 ( 
 "Did you specify a valid path to a service account key file?" 
 ); 
  
 System 
 . 
 exit 
 ( 
 1 
 ); 
  
 } 
  
 catch 
  
 ( 
 GeneralSecurityException 
  
 ex 
 ) 
  
 { 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Unable to establish secure HttpTransport:%n%s" 
 , 
  
 ex 
 ); 
  
 System 
 . 
 exit 
 ( 
 1 
 ); 
  
 } 
  
 execute 
 ( 
 client 
 , 
  
 parsedArgs 
 ); 
  
 } 
 } 

Reactivate

You can reactivate a ClientUser with the buyers.clients.users.activate method.

For example, if you temporarily revoked an individual's access to the Authorized Buyers Marketplace UI with deactivate , you can use activate to restore their access.

The following sample demonstrates how you can reactivate a ClientUser with the activate method.

REST

Request

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/clients/873721984/users/4573644:activate?alt=json
Authorization: Bearer ACCESS_TOKEN 
Content-Type: application/json

Response

{
 "name": "buyers/12345678/clients/873721984/users/4573644",
 "state": "ACTIVE",
 "email": "jessie@luxurymarscruises.mars"
}

Java

 /* 
 * Copyright 2022 Google LLC 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *    https://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */ 
 package 
  
 com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.clients.users 
 ; 
 import 
  
 com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace 
 ; 
 import 
  
 com.google.api.services.authorizedbuyersmarketplace.v1.model.ActivateClientUserRequest 
 ; 
 import 
  
 com.google.api.services.authorizedbuyersmarketplace.v1.model.ClientUser 
 ; 
 import 
  
 com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils 
 ; 
 import 
  
 java.io.IOException 
 ; 
 import 
  
 java.security.GeneralSecurityException 
 ; 
 import 
  
 net.sourceforge.argparse4j.ArgumentParsers 
 ; 
 import 
  
 net.sourceforge.argparse4j.inf.ArgumentParser 
 ; 
 import 
  
 net.sourceforge.argparse4j.inf.ArgumentParserException 
 ; 
 import 
  
 net.sourceforge.argparse4j.inf.Namespace 
 ; 
 /** 
 * This sample illustrates how to activate a client user for the given buyer, client, and user ID. 
 * 
 * <p>Activated client users can access the Authorized Buyers UI on behalf of a client. 
 * 
 * <p>Note that a client user in the "INVITED" state can not be activated, and attempting to 
 * activate it will result in an error response. 
 */ 
 public 
  
 class 
 ActivateClientUsers 
  
 { 
  
 public 
  
 static 
  
 void 
  
 execute 
 ( 
 AuthorizedBuyersMarketplace 
  
 marketplaceClient 
 , 
  
 Namespace 
  
 parsedArgs 
 ) 
  
 { 
  
 Long 
  
 accountId 
  
 = 
  
 parsedArgs 
 . 
 getLong 
 ( 
 "account_id" 
 ); 
  
 Long 
  
 clientId 
  
 = 
  
 parsedArgs 
 . 
 getLong 
 ( 
 "client_id" 
 ); 
  
 Long 
  
 clientUserId 
  
 = 
  
 parsedArgs 
 . 
 getLong 
 ( 
 "client_user_id" 
 ); 
  
 String 
  
 name 
  
 = 
  
 String 
 . 
 format 
 ( 
 "buyers/%d/clients/%d/users/%d" 
 , 
  
 accountId 
 , 
  
 clientId 
 , 
  
 clientUserId 
 ); 
  
 ClientUser 
  
 clientUser 
  
 = 
  
 null 
 ; 
  
 try 
  
 { 
  
 clientUser 
  
 = 
  
 marketplaceClient 
  
 . 
 buyers 
 () 
  
 . 
 clients 
 () 
  
 . 
 users 
 () 
  
 . 
 activate 
 ( 
 name 
 , 
  
 new 
  
 ActivateClientUserRequest 
 ()) 
  
 . 
 execute 
 (); 
  
 } 
  
 catch 
  
 ( 
 IOException 
  
 ex 
 ) 
  
 { 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Marketplace API returned error response:%n%s" 
 , 
  
 ex 
 ); 
  
 System 
 . 
 exit 
 ( 
 1 
 ); 
  
 } 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Activated client user with name \"%s\":%n" 
 , 
  
 name 
 ); 
  
 Utils 
 . 
 printClientUser 
 ( 
 clientUser 
 ); 
  
 } 
  
 public 
  
 static 
  
 void 
  
 main 
 ( 
 String 
 [] 
  
 args 
 ) 
  
 { 
  
 ArgumentParser 
  
 parser 
  
 = 
  
 ArgumentParsers 
 . 
 newFor 
 ( 
 "ActivateClientUsers" 
 ) 
  
 . 
 build 
 () 
  
 . 
 defaultHelp 
 ( 
 true 
 ) 
  
 . 
 description 
 (( 
 "Activate a client user with the given buyer, client, and user ID." 
 )); 
  
 parser 
  
 . 
 addArgument 
 ( 
 "-a" 
 , 
  
 "--account_id" 
 ) 
  
 . 
 help 
 ( 
  
 "The resource ID of the buyers resource under which the parent client was created. " 
  
 + 
  
 "This will be used to construct the name used as a path parameter for the " 
  
 + 
  
 "users.activate request." 
 ) 
  
 . 
 required 
 ( 
 true 
 ) 
  
 . 
 type 
 ( 
 Long 
 . 
 class 
 ); 
  
 parser 
  
 . 
 addArgument 
 ( 
 "-c" 
 , 
  
 "--client_id" 
 ) 
  
 . 
 help 
 ( 
  
 "The resource ID of the buyers.clients resource under which the client user was" 
  
 + 
  
 " created. This will be used to construct the name used as a path parameter for" 
  
 + 
  
 " the users.activate request." 
 ) 
  
 . 
 required 
 ( 
 true 
 ) 
  
 . 
 type 
 ( 
 Long 
 . 
 class 
 ); 
  
 parser 
  
 . 
 addArgument 
 ( 
 "-u" 
 , 
  
 "--client_user_id" 
 ) 
  
 . 
 help 
 ( 
  
 "The resource ID of the buyers.clients.users resource that is being activated. " 
  
 + 
  
 "This will be used to construct the name used as a path parameter for the " 
  
 + 
  
 "users.activate request." 
 ) 
  
 . 
 required 
 ( 
 true 
 ) 
  
 . 
 type 
 ( 
 Long 
 . 
 class 
 ); 
  
 Namespace 
  
 parsedArgs 
  
 = 
  
 null 
 ; 
  
 try 
  
 { 
  
 parsedArgs 
  
 = 
  
 parser 
 . 
 parseArgs 
 ( 
 args 
 ); 
  
 } 
  
 catch 
  
 ( 
 ArgumentParserException 
  
 ex 
 ) 
  
 { 
  
 parser 
 . 
 handleError 
 ( 
 ex 
 ); 
  
 System 
 . 
 exit 
 ( 
 1 
 ); 
  
 } 
  
 AuthorizedBuyersMarketplace 
  
 client 
  
 = 
  
 null 
 ; 
  
 try 
  
 { 
  
 client 
  
 = 
  
 Utils 
 . 
 getMarketplaceClient 
 (); 
  
 } 
  
 catch 
  
 ( 
 IOException 
  
 ex 
 ) 
  
 { 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Unable to create Marketplace API service:%n%s" 
 , 
  
 ex 
 ); 
  
 System 
 . 
 out 
 . 
 println 
 ( 
 "Did you specify a valid path to a service account key file?" 
 ); 
  
 System 
 . 
 exit 
 ( 
 1 
 ); 
  
 } 
  
 catch 
  
 ( 
 GeneralSecurityException 
  
 ex 
 ) 
  
 { 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Unable to establish secure HttpTransport:%n%s" 
 , 
  
 ex 
 ); 
  
 System 
 . 
 exit 
 ( 
 1 
 ); 
  
 } 
  
 execute 
 ( 
 client 
 , 
  
 parsedArgs 
 ); 
  
 } 
 } 
Design a Mobile Site
View Site in Mobile | Classic
Share by: