@jonathon ,
yes, I would like to invite people from Grasshopper. The idea is for the hackathon, yes.
So this is the body of my code in C#
protected override void SolveInstance(IGH_DataAccess DA)
{
string ghSpeckleStream = null;
string ghSpeckleLink = null;
var collaborators = new List<string>();
var roles = new List<string>();
Speckle.Core.Api.Stream stream = new Speckle.Core.Api.Stream();
if (!DA.GetData(0, ref ghSpeckleStream))
{
return;
}
DA.GetData(1, ref ghSpeckleLink);
DA.GetDataList(2, collaborators);
DA.GetDataList(3, roles);
var streamWrapper = new StreamWrapper(ghSpeckleStream);
var collaborator = collaborators[0];
var role = roles[0];
Task.Run(async () =>
{
try
{
var account = await streamWrapper.GetAccount();
var client = new Client(account);
var updatePermissionInput = new StreamPermissionInput
{
streamId = ghSpeckleLink,
userId = collaborator,
role = role
};
await client.StreamUpdatePermission(updatePermissionInput);
}
catch (Exception exception)
{
DA.SetData(1, $"{nameof(Exception)}: {exception.Message}");
}
}).Wait();
// }
Task.Run(async () =>
{
var account = await streamWrapper.GetAccount();
var client = new Client(account);
stream = await client.StreamGet(ghSpeckleStream);
}).Wait();
DA.SetDataList(0, stream.collaborators);
}
It fails on this line:
await client.StreamUpdatePermission(updatePermissionInput);
and this is my python code:
from specklepy.api.client import SpeckleClient
from specklepy.api.credentials import get_account_from_token
from specklepy.api.wrapper import StreamWrapper as sw
from specklepy.api.resources.stream import Resource as rs
wrapper = sw(stream_link)
print (wrapper)
client = wrapper.get_client()
print (client)
account = get_account_from_token("MY_TOKEN", wrapper.server_url)
print (account)
client.authenticate_with_account(account)
resource = rs(account,wrapper.server_url,client, (2,18,17))
print (resource)
print (" ")
update = rs.update_permission(resource, stream, user, role)
print (update)
At least here I’m pretty sure the issue is with the resource although this server version format was the only way I could find out where it was not telling me that it cannot compare text to touple. (MY_TOKEN is my token, so autentication goes well)
The C# code interestingly fails differently, if I provide input differently. So if the input is:
strteam: ID
user: ID
role: owner
The message is:
Exception: Request failed with errors
And with these inputs:
strteam: https://speckle.xyz/streams/ID
user: ID
role: stream:contributor
This is the message:
Exception: Your request failed on the server side