public async Task <AuthResponse> LoginWithOpenIDConnect(string idToken, bool createAccount = true) { var request = new LoginWithOpenIdConnectRequest { TitleId = _config.TitleId, ConnectionId = _config.ConnectionId, IdToken = idToken, CreateAccount = createAccount, InfoRequestParameters = new GetPlayerCombinedInfoRequestParams { GetUserAccountInfo = true } }; try { var response = await PlayFabClientAPI.LoginWithOpenIdConnectAsync(request); if (response.Error != null) { return(GetAuthResponse(tokenExpiration: DateTime.UtcNow, errorMessage: response.Error.ErrorMessage)); } return(GetAuthResponse((DateTime)response.Result.EntityToken.TokenExpiration, null, response.Result?.SessionTicket, null, response.Result)); } catch (Exception exception) { HandleError(exception); return(GetAuthResponse(tokenExpiration: DateTime.UtcNow, errorMessage: exception.Message)); } }
public async Task <AuthResponse> LoginWithOpenIDConnectAsync(string idToken, ClaimsIdentity identity, AuthenticationProperties authenticationProperties, bool createAccount = true) { var request = new LoginWithOpenIdConnectRequest { ConnectionId = config.ConnectionId, IdToken = idToken, CreateAccount = createAccount, InfoRequestParameters = new GetPlayerCombinedInfoRequestParams { GetUserAccountInfo = true, GetUserVirtualCurrency = true } }; try { var response = await PlayFabClientAPI.LoginWithOpenIdConnectAsync(request); if (response.Error != null) { return(await GetAuthResponseAsync(tokenExpiration : DateTime.UtcNow, errorMessage : response.Error.ErrorMessage)); } var playFabResult = new PlayFabResult { DisplayName = response.Result?.InfoResultPayload?.AccountInfo?.Username, SessionTicket = response.Result?.SessionTicket, PlayFabId = response.Result?.PlayFabId, Budget = response.Result?.InfoResultPayload?.UserVirtualCurrency?[config.Currency] ?? 0 }; return(await GetAuthResponseAsync((DateTime)response.Result.EntityToken.TokenExpiration, playFabResult, (bool)response.Result?.NewlyCreated, identity : identity, authenticationProperties : authenticationProperties)); } catch (Exception exception) { HandleError(exception); return(await GetAuthResponseAsync(tokenExpiration : DateTime.UtcNow, errorMessage : exception.Message)); } }