Ejemplo n.º 1
0
        private async void Authorize(string tokenId)
        {
            LogMsg(string.Format("GoogleAuth.Authorize called: {0}", tokenId));

            var apiInstance = new AuthApi("https://auth.angusmf.com");


            try
            {
                var response = await apiInstance.GoogleAsyncWithHttpInfo(new UserView(tokenId));

                if (response.StatusCode == 200)
                {
                    LogMsg(string.Format("Success! Token = {0}", response.Data.Token));


                    //MessageBroker.Default.Publish(new ClientAuthTokenReceived(response.Data.Token, null));
                    MessageBroker.Default.Publish(new ServerAuthTokenReceived(response.Data.Token));
                }
                else
                {
                    LogMsg(string.Format("Error: Received response code {0} during authorization", response.StatusCode));
                }
            }
            catch (ApiException e)
            {
                LogMsg(string.Format("e.Data: {0} \n e.ErrorCode: {1} \n e.ErrorContent: {2} \n e.Message: {3}", e.Data, e.ErrorCode, e.ErrorContent, e.Message));
            }
            catch (Exception e)
            {
                LogMsg("Exception when calling apiInstance.AuthenticateWithHttpInfo: " + e.Message);
            }
        }