Unity SDK package: authentication v1.3.0
Starting from v1.3.0 the SDK will cache twitch user data in PlayerPrefs. When the game startup again, the twitch initialization can restore the data. SDK will validate if access token is still valid and try to refresh if not. If initialization succeed, the game can start using the available twitch data. If initialization failed, the game should prompt the user to login to twitch.
async void Start(){// although there is no explicit dependency at the moment, it's best to initialize the basic auth firstawait AuthController.InitAsync();// load twitch data from cache, validate, and refresh token if necessaryvar twitchData = await TwitchController.InitAsync();if (twitchData == null){// init fail, user should login to twitch againtwitchData = await TwitchController.LoginToTwitch(...);// if login succeed, twitch data is ready to use either in return object or by CurrentUservar id = TwitchController.CurrentUser.UserInfo.Id;}else{// twitch data is ready to use// CurrentUser is same as the twitch data return by InitAsyncvar id = TwitchController.CurrentUser.UserInfo.Id;// TwitchApi is also ready for usevar users = await TwitchController.TwitchApi.Helix.Users.GetUsersAsync(new List<string>(){ id });}}