public static void OnAuthVk(AuthUserInfo userInfo, string type) { var main = MAIN.getMain; var auth = new AuthApiRequest(); auth.Aid = main.applicationID; auth.Ui = userInfo; auth.Type = type; main.network.ApiRequest(Api.CmdName.Auth, JsonUtility.ToJson(auth)); }
/// <summary> /// Get a full access token for the main TYWI API. /// </summary> /// <param name="accessToken">The access token</param> /// <returns></returns> public AccessResponse Authorise(string accessToken) { try { string tokenUri = TywiConfiguration.AuthServiceUri + UriTemplates.AUTHORISE_REQUEST; AccessRequest accessRequest = new AccessRequest() { clientSecret = _account.ClientSecret, clientId = _account.ClientId, code = accessToken }; AuthApiRequest<AccessRequest, AccessResponse> request = new AuthApiRequest<AccessRequest, AccessResponse>(tokenUri, Http.HttpUtilities.Methods.POST, accessRequest); return this.ProcessRequest<AccessRequest, AccessResponse>(request); } catch (Exception exc) { throw new AccessDeniedException(String.Format("Authorisation failed for account {0}", _account.Name), exc); } }
/// <summary> /// Request an access token. This is a temporary token that grants us short-term access to the main /// athorisation endpoint /// </summary> public TokenResponse RequestToken() { string absoluteUri = null; try { string relativeUri = String.Format(UriTemplates.TOKEN_REQUEST, _account.Name, _account.ClientId); absoluteUri = TywiConfiguration.AuthServiceUri + relativeUri; AuthApiRequest<string, TokenResponse> request = new AuthApiRequest<string, TokenResponse>(absoluteUri, Http.HttpUtilities.Methods.GET, null); return this.ProcessRequest<string, TokenResponse>(request); } catch (Exception exc) { throw new AccessDeniedException(String.Format("Authorisation failed for account {0}", _account.Name), exc); } }