addon.auth

Available in userscripts ✔️
Available in persistent scripts ✔️
Required manifest permissions None

Description

Allows addons to get information about the current Scratch account session.

Examples

Reacting to auth info change

addon.auth.addEventListener("change", function() {
  console.log(addon.auth.isLoggedIn);
});

Properties

addon.auth.scratchLang

Type String
Nullable No

Language of the Scratch website.
This language option can be changed by the user in the footer of Scratch’s website.
This property changing does not fire a change event.

addon.auth.isLoggedIn

Type Boolean
Nullable No

Whether the user is logged in or not.

addon.auth.username

Type String
Nullable Yes

Username of the currently logged in user.
Will be null if addon.auth.isLoggedIn is false.

addon.auth.userId

Type Number
Nullable Yes

User ID of the currently logged in user.
Will be null if addon.auth.isLoggedIn is false.

addon.auth.xToken

Type String
Nullable Yes

Value of the X-Token header used in the Scratch REST API.
Will be null if addon.auth.isLoggedIn is false.

addon.auth.csrfToken

Type String
Nullable Yes

Value of the scratchcsrftoken cookie.
Will be null if addon.auth.isLoggedIn is false.

Events

change

Fires when any of isLoggedIn, username, userId, xToken or csrfToken change.


Last updated at 25 May 2021 by World_Languages on commit e329d03. Improve this page.