Archicad 29 C++ API
Loading...
Searching...
No Matches
ACAPI::GSID Class Referencefinal

Serves as a means to query various unique identifiers of the logged-in user, facilitating stable user identification. More...

#include <GSID.hpp>

Inheritance diagram for ACAPI::GSID:
ACAPI::Object

Public Member Functions

Result< std::set< GS::UniString > > GetOrganizationIds () const
 Function used to query the organization identifiers belonging to the logged-in user.
 
Result< GS::UniString > GetUserId () const
 Function used to query the GSID User ID of the logged-in user.
 
- Public Member Functions inherited from ACAPI::Object
 Object (std::shared_ptr< Impl::ObjectImpl > impl)
 Constructs a new object.
 
const API_TokenGetToken () const
 Get the token for this object.
 

Friends

Result< GSIDCreateGSIDObject ()
 Creates an instance of class GSID.
 

Additional Inherited Members

- Protected Member Functions inherited from ACAPI::Object
 ~Object ()
 Default destructor.
 
- Protected Attributes inherited from ACAPI::Object
std::shared_ptr< Impl::ObjectImplmImpl
 Impl object given by constructor.
 

Detailed Description

Serves as a means to query various unique identifiers of the logged-in user, facilitating stable user identification.

Since
Archicad 28
Remarks
These identifiers are stable; for the same user and organization, the same result is returned even if queried from different Archicad versions and computers. It is not possible to infer any personal information (such as the organization's or the user's name or e-mail address) through them. They are not tied to license technology, identity, or content; for example, they are queryable even in demo mode, given the user is signed in with a GSID account in Archicad.

Member Function Documentation

◆ GetOrganizationIds()

Result< std::set< GS::UniString > > ACAPI::GSID::GetOrganizationIds ( ) const

Function used to query the organization identifiers belonging to the logged-in user.

Returns
If successful, returns a Result object containing the user's organization identifiers. Returns an Error object otherwise.
Example code snippet from Test / Protection
static std::set<GS::UniString> GetAuthorizedUsers (void); // { ... }
static std::set<GS::UniString> GetAuthorizedOrganizations (void); // { ... }
bool IsUserAuthorizedToUseAddOn (void)
{
auto gsid = ACAPI::CreateGSIDObject ();
if (gsid.IsErr ())
return false;
auto userId = gsid->GetUserId ();
auto userOrgs = gsid->GetOrganizationIds ();
auto authorizedUsers = GetAuthorizedUsers ();
auto authorizedOrgs = GetAuthorizedOrganizations ();
if (userId.IsOk ())
if (authorizedUsers.find (*userId) != authorizedUsers.end ())
return true;
if (userOrgs.IsOk ())
for (const auto& userOrg : *userOrgs)
if (authorizedOrgs.find (userOrg) != authorizedOrgs.end ())
return true;
// User not entitled to use Add-On (as e.g. they do not possess a license for your Add-On)
return false;
}

◆ GetUserId()

Result< GS::UniString > ACAPI::GSID::GetUserId ( ) const

Function used to query the GSID User ID of the logged-in user.

Returns
If successful, returns a Result object containing the user's GSID User ID. Returns an Error object otherwise.
Example code snippet from Test / Protection
static std::set<GS::UniString> GetAuthorizedUsers (void); // { ... }
static std::set<GS::UniString> GetAuthorizedOrganizations (void); // { ... }
bool IsUserAuthorizedToUseAddOn (void)
{
auto gsid = ACAPI::CreateGSIDObject ();
if (gsid.IsErr ())
return false;
auto userId = gsid->GetUserId ();
auto userOrgs = gsid->GetOrganizationIds ();
auto authorizedUsers = GetAuthorizedUsers ();
auto authorizedOrgs = GetAuthorizedOrganizations ();
if (userId.IsOk ())
if (authorizedUsers.find (*userId) != authorizedUsers.end ())
return true;
if (userOrgs.IsOk ())
for (const auto& userOrg : *userOrgs)
if (authorizedOrgs.find (userOrg) != authorizedOrgs.end ())
return true;
// User not entitled to use Add-On (as e.g. they do not possess a license for your Add-On)
return false;
}

Friends And Related Symbol Documentation

◆ CreateGSIDObject

Result< GSID > CreateGSIDObject ( )
friend

Creates an instance of class GSID.

Returns
Returns a new GSID instance.