public bool AuthTokenReq(int playerId, string token) { AuthTokenReq request = new AuthTokenReq(); request.token = token; bool result = clientCore.Transmitter.SendToGame(request, (int)EGMI.EGMI_AUTH_TOKEN_REQ); return(result); }
/// <summary> /// Gets the client auth token async. /// </summary> /// <returns>The client auth token async.</returns> /// <param name="code">Code.</param> public async Task <string> GetClientAuthTokenAsync(string code) { const string req = "/oauth/token"; var p = new AuthTokenReq { code = code, client_id = userConfig.ClientId, client_secret = userConfig.ClientSecret }; var rz = await doPostRequestAsync(req, p, false); var rsp = JsonConvert.DeserializeObject <AuthTokenRsp>(rz); return(rsp.access_token); }
public AuthTokenResp Token([FromBody] AuthTokenReq authTokenReq) { ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)((_param1, _param2, _param3, _param4) => true); try { this.stringBuilder.Append(authTokenReq.Username); this.stringBuilder.Append(":"); this.stringBuilder.Append(authTokenReq.Password); string str1 = "Basic " + AuthController.Base64Encode(this.stringBuilder.ToString()); this.logger.Info("Starting::: Token Generation Calls. Header " + str1); if (str1.StartsWith("Basic")) { string[] strArray1 = Encoding.UTF8.GetString(Convert.FromBase64String(str1.Substring("Basic ".Length).Trim())).Split(':'); RestClient restClient = new RestClient(this.UserValidationBaseURL + "ValidateUserNew?Username="******"&Password="******"cache-control", "no-cache"); restRequest.AddHeader("Content-Type", "application/json"); IRestResponse restResponse = restClient.Execute((IRestRequest)restRequest); AuthResponseBody authResponseBody1 = new AuthResponseBody(); AuthResponseBody authResponseBody2 = JsonConvert.DeserializeObject <AuthResponseBody>(restResponse.Content); if (authResponseBody2.Status == "00") { string[] strArray2 = authResponseBody2.Result.Split('|'); this.logger.Info("Result::: DB Query Response " + authResponseBody2.Result); if (strArray2[0] == "1" && strArray2[1] == "2") { Claim[] claimArray = new Claim[1] { new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", strArray1[0] + "|" + strArray2[1]) }; SigningCredentials signingCredentials = new SigningCredentials((SecurityKey) new SymmetricSecurityKey(Encoding.UTF8.GetBytes("jlklk;lkl;wkwipoiuwoulwlrwwqxdwfrr")), "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256"); DateTime? expires = new DateTime?(DateTime.Now.AddMinutes(1.0)); string str2 = new JwtSecurityTokenHandler().WriteToken((SecurityToken) new JwtSecurityToken("wemabank.com", "cbn.gov.ng", (IEnumerable <Claim>)claimArray, expires: expires, signingCredentials: signingCredentials)); this.authTokenResp = new AuthTokenResp() { ResponseCode = this.successResponse.Status, ResponseMessage = this.successResponse.Msg, Token = str2 }; return(this.authTokenResp); } } } this.authTokenResp = new AuthTokenResp() { ResponseCode = this.errorResponse.Status, ResponseMessage = this.errorResponse.Msg, Token = "" }; return(this.authTokenResp); } catch (Exception ex) { this.logger.Info("Entering Exceptions::: message:-" + ex.Message); this.authTokenResp = new AuthTokenResp() { ResponseCode = this.errorResponse.Status, ResponseMessage = this.errorResponse.Msg, Token = ex.Message }; return(this.authTokenResp); } }