Skip to main content

Editor.IAuthorization

Class

Component that allows you to check whether Lens Studio is authorized, as well as get authorization.

Component that allows you to check whether Lens Studio is authorized, as well as get authorization. Requires snap_auth_token in the module.json of your plugin.

Index

Example

// Resolve IAuthorization to check and manage Snapchat login state.
// Requires `snap_auth_token` in the plugin's module.json.
try {
const auth = this.pluginSystem.findInterface(
Editor.IAuthorization.interfaceId
) as Editor.IAuthorization;
if (Editor.isNull(auth)) {
console.log('IAuthorization not available');
return;
}
console.log('isAuthorized:', auth.isAuthorized);

this.connections.push(
auth.onAuthorizationChange.connect((authorized: boolean) => {
console.log('Authorization changed:', authorized);
if (authorized) {
console.log('idToken:', auth.idToken);
}
})
);

if (!auth.isAuthorized) {
auth.authorize();
}
} catch (e) {
console.warn('IAuthorization could not be resolved:', e);
}

Extends

Properties

idToken

readonly idToken: string

The authorization token string from the identity provider.


interfaceId

static interfaceId: InterfaceId

The unique identifier for the IAuthorization interface.


isAuthorized

readonly isAuthorized: boolean

Current authorization state.


onAuthorizationChange

readonly onAuthorizationChange: signal1<boolean, void>

Signal that responds to changes in authorization state.

Methods

authorize()

authorize(): void

Initiate the authorization flow.

Returns

void


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

IPluginComponent.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

IPluginComponent.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

IPluginComponent.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

IPluginComponent.isSame