groupsharekit.net icon indicating copy to clipboard operation
groupsharekit.net copied to clipboard

Authentication in sample code not working - token parameter required

Open kothes-support opened this issue 4 years ago • 2 comments

Hello, I just downloaded the Groupsharekit from NuGet in Visual Studio and wanted to test this sample code:

var groupShareClient = await GroupShareClient.AuthenticateClient(userName, password, new Uri("http://yourgroupshareaddress"), GroupShareClient.AllScopes);

var users = await groupShareClient.User.GetAllUsers();

foreach (var user in users)
{
    Console.WriteLine(user.DisplayName +" loves Groupshare!");
}

Unfortunately it was not working because a token parameter is required for this method: GroupShareClient.AuthenticateClient(string token, string user, string password, string bearerId, Uri baseAddress, IEnumerable<string> scopes)

I am not that familiar with using REST-API, I just want to use the C# wrapper. But it does not seem that there is any more sample code anywhere or is there? Where do I get the required token from? ist it stored somewhere in the Groupshare server? Any additional documentation would be greatly appreciated. Thanks!

kothes-support avatar Sep 22 '21 14:09 kothes-support

I was finally able to fix your sample code and make this example work. Just in case it might be useful to someone.

But still I would like to know if there is an API-Doc for all the c# classes, methods and data types? Some simple examples would be very nice, too.

var token = await GroupShareClient.GetRequestToken("user", "password", new Uri("http://myServer"), GroupShareClient.AllScopes);
Console.WriteLine(token);

var groupShareClient = await GroupShareClient.AuthenticateClient(token, "user", "password", null, new Uri("http://myServer"), GroupShareClient.AllScopes);

var users = await groupShareClient.User.GetAllUsers(new UsersRequest(1, 1, Int16.MaxValue));

foreach (UserDetails ur in users.Items)
{
       Console.WriteLine(ur.DisplayName + " loves Groupshare!");
}

kothes-support avatar Sep 24 '21 10:09 kothes-support

I realized that the information inside the object "UserDetails" is incomplete. Besides the "DisplayName" all other properties have value "null". This way it is practically useless when trying to loop over all users and looking for a specific e-mail or ID e.g.. I also posted the problem with screenshot to the RWS community boards: https://community.rws.com/developers-more/developers/language-developers/f/sdk_qa/40616/groupsharekit---getallusers-return-incomplete-information

kothes-support avatar Mar 01 '22 12:03 kothes-support