/// <summary> /// Authenticate to Xbox Live. /// First it refreshes the Windows Live token, then it authenticates to XASU and XSTS /// </summary> /// <returns>Returns true on success, false otherwise</returns> public async Task <bool> AuthenticateAsync() { try { logger.LogTrace("AuthenticateAsync() called"); logger.LogTrace("AuthenticateAsync: Calling RefreshLiveTokenAsync"); WindowsLiveResponse windowsLiveTokens = await RefreshLiveTokenAsync(RefreshToken); logger.LogTrace("AuthenticateAsync: Constructing AccessToken"); AccessToken = new AccessToken(windowsLiveTokens); logger.LogTrace("AuthenticateAsync: Constructing RefreshToken"); RefreshToken = new RefreshToken(windowsLiveTokens); logger.LogTrace("AuthenticateAsync: Calling AuthenticateXASUAsync"); UserToken = await AuthenticateXASUAsync(AccessToken); logger.LogTrace("AuthenticateAsync: Calling AuthenticateXSTSAsync"); XToken = await AuthenticateXSTSAsync(UserToken, DeviceToken, TitleToken); } catch (HttpRequestException ex) { logger.LogError(ex, "AuthenticateAsync failed due to HTTP error: {}", ex.Message); return(false); } logger.LogTrace("AuthenticateAsync: Setting UserInformation"); UserInformation = XToken.UserInformation; return(true); }
public BaseAuthToken(XASResponse tokenResponse) { Jwt = tokenResponse.Token; Issued = tokenResponse.IssueInstant; Expires = tokenResponse.NotAfter; UserInformation = tokenResponse.DisplayClaims["xui"][0]; }
public bool Authenticate() { WindowsLiveResponse windowsLiveTokens = RefreshLiveToken(RefreshToken); AccessToken = new AccessToken(windowsLiveTokens); RefreshToken = new RefreshToken(windowsLiveTokens); UserToken = AuthenticateXASU(AccessToken); XToken = AuthenticateXSTS(UserToken, DeviceToken, TitleToken); UserInformation = XToken.UserInformation; return(true); }
public async Task <bool> AuthenticateAsync() { WindowsLiveResponse windowsLiveTokens = await RefreshLiveTokenAsync(RefreshToken); AccessToken = new AccessToken(windowsLiveTokens); RefreshToken = new RefreshToken(windowsLiveTokens); UserToken = await AuthenticateXASUAsync(AccessToken); XToken = await AuthenticateXSTSAsync(UserToken, DeviceToken, TitleToken); UserInformation = XToken.UserInformation; return(true); }
/// <summary> /// Update tokens and userinformation from a JSON file /// </summary> /// <param name="sourceFilePath">Source JSON filepath</param> /// <returns>Returns true on success, false otherwise</returns> public async Task <bool> UpdateFromJsonFileAsync(string sourceFilePath) { try { AuthenticationService tempObj = await LoadFromJsonFileAsync(sourceFilePath); this.RefreshToken = tempObj.RefreshToken; this.AccessToken = tempObj.AccessToken; this.UserToken = tempObj.UserToken; this.XToken = tempObj.XToken; this.DeviceToken = tempObj.DeviceToken; this.TitleToken = tempObj.TitleToken; this.UserInformation = tempObj.UserInformation; } catch (Exception exc) { logger.LogError("UpdateFromJsonFileAsync failed, error: {}", exc); return(false); } return(true); }