public async Task <string> Login(PasswordNameModel model) { var response = await webRequestHelper.SendRequest($"{autharizationApiUrl}/api/account/login", "post", ToJson(model)); UserAPIModel apiUser = webRequestHelper.GetObjectFromResponse <UserAPIModel>(response); if (apiUser == null) { return(null); } return(!string.IsNullOrEmpty(response.Headers["Authorization"]) ? response.Headers["Authorization"] : null); }
public async Task <TokenModel> GetAuthorizationToken(HttpRequest httpRequest, string redirectUri) { var codeModel = GetCode(httpRequest); var accessTokenUri = GetUriToGetToken(redirectUri, codeModel.Code); var accessTokenModel = webRequest.GetObjectFromResponse <TokenModel>(await webRequest.SendRequest(accessTokenUri, "get", "")); if (accessTokenModel != null && accessTokenModel.Access_Token != null) { var uriToGetUser = new UriBuilder("https://graph.facebook.com/me"); uriToGetUser.AddGetParameter("access_token", accessTokenModel.Access_Token); var face = webRequest.GetObjectFromResponse <FacebookUserModel>(await webRequest.SendRequest(uriToGetUser.ToString(), "get", "")); accessTokenModel.User_Id = face.Id; } return(accessTokenModel); }
/// <summary> /// 发起网络请求 /// </summary> /// <param name="interfaceName">接口名称</param> /// <param name="parameter">可选参数(要同时传入参数名和参数值,例:name='张三')</param> /// <returns>请求的协程</returns> public Coroutine SendRequest(string interfaceName, params string[] parameter) { return(_helper.SendRequest(interfaceName, parameter)); }
public async Task <TokenModel> GetAuthorizationToken(HttpRequest httpRequest, string redirectUri) { var codeModel = GetCode(httpRequest); var accessTokenUri = GetUriToGetToken(redirectUri, codeModel.Code); var accessTokenModel = webRequest.GetObjectFromResponse <Models.TokenModel>(await webRequest.SendRequest(accessTokenUri, "get", "")); return(accessTokenModel); }