[SpecklePy] Sending an invite to add the user to the speckle stream

Hi,
Is it possible to add users to the Speckle Stream through SpecklePy API? If so, how can it be done? I haven’t found any information in the documentation nor examples on the official SpecklePy repository.
e.g.
stream.invite_users_to_stream(email=foo@gmail.com)

stream.update_permission() could possibly work, but does it actually add the people to the stream or is it only for users that are already added to it.

Within the api.resources.stream is the invite method. This doesn’t add a user to the stream permissions until that user has accepted the invite and created account with the same email

invite( stream_id, email, user_id, role, message )

where stream_id {str} is the id of the stream to invite the user to

and you should use either:
email {str} as the email of the user to invite OR user_id {str} the id of the user to invite (only valid for users already active on the server)

role {str} is the role to assign to the user (defaults to stream:contributor)

and lastly message {str} which is the message to send along with this invite to the specified user

this method returns a bool if the invite sending was successful.

An invite_batch method is also available.


It has been previously requested that there could be a webhook event for when an invite has been accepted, I’ll check what the status/progress is on that.


Also a previous discussion for this for when you have control of the server:

In that thread, @Baris has a solution (with .NET) to register users directly. This is, again, not for the public speckle.xyz but where the server is self-hosted.

4 Likes

This is exactly what I am looking for, thank you!

2 Likes

Hi,

I’m trying this with GraphQL and getting “You do not have the required privileges.”, what is the needed setup more than being stream owner to be able to invite another user to a stream?

You will need to pre-register your app on the server for this kind of integration to work. The send invite scope is not allowed on personal access tokens or public apps because this could open up to a malicious user spamming others (eg, "Mr. Bad Hacker invited you to stream “Click here to access your funds”).

See here for how to do this.

Okay how does it work with the speckle.xyz?

A post was merged into an existing topic: Speckle serverInviteCreate graphQl query is throwing error You do not have the required privileges

The short answer is that we don’t support this for you to send invites to our server.

@samberger and @mtam

we actually have a similar task at hand :slight_smile:

Okey, do you plan to keep it that way?