Service Accounts - how to create one, and how to use it through .NET SDK

新規投稿

コメント

2件のコメント

  • kendomen

    I think the docs are confusing on that too but here's my understanding.

     

     

    App == ServiceAccount. 

     

    app.png

     

    app2.png

     

    So for example, adminClient == ServiceAccount.

     

     static async Task MainAsync()
            {
                // rename the private_key.pem.example to private_key.pem and put your JWT private key in the file
                var privateKey = File.ReadAllText(PRIVATE_KEY_FILE);
    
                var boxConfig = new BoxConfig(CLIENT_ID, CLIENT_SECRET, ENTERPRISE_ID, privateKey, JWT_PRIVATE_KEY_PASSWORD, JWT_PUBLIC_KEY_ID);
                var boxJWT = new BoxJWTAuth(boxConfig);
    
                var adminToken = boxJWT.AdminToken();
                Console.WriteLine("Admin Token: " + adminToken);
                Console.WriteLine();
    
                var adminClient = boxJWT.AdminClient(adminToken);  // adminClient == serviceAccount
               
                var userDetails = await adminClient.UsersManager.GetCurrentUserInformationAsync();
                Console.WriteLine("\tAdmin User Details:");
                Console.WriteLine("\tId: {0}", userDetails.Id);
                Console.WriteLine("\tName: {0}", userDetails.Name);
                Console.WriteLine("\tStatus: {0}", userDetails.Status);
                Console.WriteLine();
               
                var users = await adminClient.UsersManager.GetEnterpriseUsersAsync();
                users.Entries.ForEach(i =>
                {
                    Console.WriteLine("\t{0}", i.Name);
                    Console.WriteLine("\t{0}", i.Status);
    
                    if (i.Status == "active")
                    {
                        var userToken = boxJWT.UserToken(i.Id);
                        var userClient = boxJWT.UserClient(userToken, i.Id);
    
                        Task u = getUserItems(userClient, i.Id);
                        u.Wait();                                       
                    }
    
                });
            }

    https://github.com/kendomen/BoxDotNetGetManagedUsersItems

     

    0
    コメントアクション パーマリンク
  • rajesh4851

    Thanks for detailed message;

    Can you also help me to understand creating a Service Accounts using JAVA SDK? provide the sample code as well?

     

    Regards,

    Raj

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。