Editor.IAuthorization
ClassComponent 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
Properties
Methods
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
readonlyidToken:string
The authorization token string from the identity provider.
interfaceId
staticinterfaceId:InterfaceId
The unique identifier for the IAuthorization interface.
isAuthorized
readonlyisAuthorized:boolean
Current authorization state.
onAuthorizationChange
readonlyonAuthorizationChange:signal1<boolean,void>
Signal that responds to changes in authorization state.
Methods
authorize()
authorize():
void
Initiate the authorization flow.
Returns
void
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean