Preparing search index...

    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.

        // 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);
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    idToken: string

    The authorization token string from the identity provider.

    interfaceId: InterfaceId

    The unique identifier for the IAuthorization interface.

    isAuthorized: boolean

    Current authorization state.

    onAuthorizationChange: signal1<boolean, void>

    Signal that responds to changes in authorization state.

    Methods

    • Initiate the authorization flow.

      Returns void

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean