Beispiel #1
0
        private OAuthData GetUserData()
        {
            //We now have the credentials, so we can start making API calls
            using (var context = new SPContext(Office365Url, new Components.AuthenticationUtil.Methods.OAuth()))
            {
                var userDetails = context.Web.CurrentUser;

                context.Load(userDetails,
                             usr => usr.Email,
                             usr => usr.Id,
                             usr => usr.LoginName,
                             usr => usr.Title,
                             usr => usr.UserId);

                context.ExecuteQuery();

                var uid  = userDetails.Id.ToString(CultureInfo.InvariantCulture);
                var data = new OAuthData
                {
                    ClientId   = uid,
                    ClientType = ClientType,
                    Email      = userDetails.Email,
                    UserName   = SanitizeUserName(userDetails.LoginName),
                    AvatarUrl  = string.Empty,
                    CommonName = userDetails.Title
                };

                return(data);
            }
        }
        public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            if (response == null)
            {
                throw new ArgumentNullException("response");
            }

            var user = _context.Users.Where(x => x.Id == _requestingUserId).First();
            var data = new OAuthData
            {
                Token         = response.Token,
                Secret        = response.TokenSecret,
                TokenType     = TokenType.RequestToken,
                TokenProvider = _tokenProvider,
                LinkedInUsers = new List <User> {
                    user
                }
            };

            _context.OAuthData.Add(data);
            _context.SaveChanges();
        }
            public static OAuthData Deserialize(string content)
            {
                var result = new OAuthData();
                Dictionary <string, object> dict =
                    JsonConvert.DeserializeObject <Dictionary <string, object> >(content);

                if (dict.ContainsKey("error"))
                {
                    result.Error            = dict["error"].ToString();
                    result.ErrorDescription = dict.ContainsKey("error_description") ? dict["error_description"].ToString() : "";
                }
                if (dict.ContainsKey("access_token"))
                {
                    result.AccessToken      = dict["access_token"].ToString();
                    result.TokenType        = dict["token_type"].ToString();
                    result.ExpiresInSeconds = Convert.ToInt32(dict["expires_in"]);
                    result.RefreshToken     = dict["refresh_token"].ToString();
                    result.ClientId         = dict["client_id"].ToString();
                    result.RefreshTokenLifeTimeInMinutes =
                        Convert.ToInt32(dict["clientRefreshTokenLifeTimeInMinutes"]);
                    result.IssuedOn = DateTime.Now;
                }

                return(result);
            }
        private Core.Entities.User AcceptFacebookOAuthToken(FacebookOAuthResult facebookOAuthResult)
        {
            Condition.Requires(facebookOAuthResult).IsNotNull();

            // Grab the code.
            string code = facebookOAuthResult.Code;

            // Grab the access token.
            FacebookOAuthClient facebookOAuthClient = FacebookOAuthClient;
            dynamic             result = facebookOAuthClient.ExchangeCodeForAccessToken(code);

            var oauthData = new OAuthData
            {
                OAuthProvider = OAuthProvider.Facebook,
                AccessToken   = result.access_token,
                ExpiresOn     = DateTime.UtcNow.AddSeconds(result.expires)
            };

            // Now grab their info.
            var     facebookWebClient = new FacebookWebClient(oauthData.AccessToken);
            dynamic facebookUser      = facebookWebClient.Get("me");

            oauthData.Id = facebookUser.id;


            // Not sure how to Inject an IUserService because it requires a Session .. which I don't have.
            var userService = new UserService(DocumentSession);

            // Now associate this facebook user to an existing user OR create a new one.
            return(userService.CreateOrUpdate(oauthData, facebookUser.username, facebookUser.name, facebookUser.email));
        }
        public void Init()
        {
            _verifyTokenMock = new Mock <IProcess <VerifyUserLinkedInAccessTokenParams, UserAccessTokenResultViewModel> >();
            _verifyTokenMock.Setup(x => x.Execute(It.IsAny <VerifyUserLinkedInAccessTokenParams>())).Returns(new UserAccessTokenResultViewModel {
                AccessTokenValid = true
            });

            _createPositionMock = new Mock <IProcess <CreatePositionParams, PositionDisplayViewModel> >();
            var createCompanyCmd = new CreateCompanyCommand(_serviceFactory.Object);

            _process = new LinkedInPositionSearchProcesses(_context, _verifyTokenMock.Object, createCompanyCmd, _createPositionMock.Object, null);

            // Initialize user with test (but valid) access token data
            _user = new User();
            var oauth = new OAuthData
            {
                Token         = "bfcf3fe4-b4d4-4f37-9d32-292ae9d45347",
                Secret        = "f66673b2-5877-4fbf-80e0-3826ca9f7eed",
                TokenProvider = TokenProvider.LinkedIn,
                TokenType     = TokenType.AccessToken,
            };

            oauth.LinkedInUsers.Add(_user);
            _user.LinkedInOAuthData = oauth;
            _context.Users.Add(_user);
            _context.OAuthData.Add(oauth);
            _context.SaveChanges();
        }
        public void Read()
        {
            authenticateMessageCounter = 0;

            //This function will get the twitter authentication data for this host name from the db
            oAuthData = DataContext.GetoAuthData();
            if (oAuthData.OAuthConsumerKey == null || oAuthData.OAuthConsumerSecret == null)
            {
                return;
            }

            //This function will get the twitter accounts from the db
            List <ScreenNameToLoad> screenNamesToLoad = DataContext.GetScreenNames();

            if (screenNamesToLoad.Count == 0)
            {
                return;
            }

            runId = DataContext.GetMaxRunID() + 1;

            foreach (var screenNameToLoad in screenNamesToLoad)
            {
                //Console.WriteLine(screenNameToLoad.ScreenName);
                if (done)
                {
                    break;
                }

                currentScreenName = screenNameToLoad.ScreenName;

                /*-----*/
                string maxid = DataContext.GetMaxMessageIdForUser(currentScreenName);

                try
                {
                    ReadTweets(screenNameToLoad.ScreenName, screenNameToLoad.IsFirstTime);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error in foreach(var screenNameToLoad ... : ReadTweets --> " + e.Message);
                }

                while (!finishedFlag)
                {
                    Thread.Sleep(500);
                }

                finishedFlag = false;
                finishedToProcessScreenName = false;
                pageCounter = 0;

                /*-----*/
                Console.WriteLine(string.Format("{0, 5}  {1, 5}  {2, 5}", currentScreenName, maxid, DataContext.GetMaxMessageIdForUser(currentScreenName)));
                Console.WriteLine(string.Format("aouth: {0}", authenticateMessageCounter));
            }
            Console.ReadKey();
            DataContext.InsertRowsUpdateLog(Environment.MachineName, statusCounter, authenticateMessageCounter);
        }
Beispiel #7
0
        public User CreateOrUpdate(OAuthData oAuthData, string userName, string fullName, string email)
        {
            // Lets find an existing user for the provider OR the email address if the provider doesn't exist.
            User user = DocumentSession
                        .Query <User>()
                        .SingleOrDefault(x =>
                                         x.OAuthData.Any(y => y.Id == oAuthData.Id &&
                                                         y.OAuthProvider == oAuthData.OAuthProvider)) ??
                        DocumentSession
                        .Query <User>()
                        .SingleOrDefault(x => x.Email == email);

            if (user != null)
            {
                // User exists, so lets update the OAuth data, for this user.
                if (user.OAuthData != null)
                {
                    OAuthData existingProvider =
                        user.OAuthData.SingleOrDefault(x => x.OAuthProvider == oAuthData.OAuthProvider);
                    if (existingProvider != null)
                    {
                        user.OAuthData.Remove(existingProvider);
                    }
                }
                else
                {
                    user.OAuthData = new List <OAuthData>();
                }

                user.OAuthData.Add(oAuthData);
            }
            else
            {
                // Ok. No user at all. We create one and store it.
                user = new User
                {
                    DisplayName  = userName,
                    Email        = email,
                    Id           = null,
                    FullName     = fullName,
                    CreatedOn    = DateTime.UtcNow,
                    IsActive     = true,
                    OAuthData    = new List <OAuthData>(),
                    FavoriteTags = new List <string> {
                        "ravendb", "c#", "asp.net-mvc3"
                    }
                };
                user.OAuthData.Add(oAuthData);
            }

            DocumentSession.Store(user);

            return(user);
        }
        public static OAuthData GetoAuthData()
        {
            DataTable table = DataHelper.GetoAuthData(Environment.MachineName);
            OAuthData data  = new OAuthData();

            foreach (DataRow row in table.Rows)
            {
                data.OAuthConsumerKey    = row.Field <string>("ConsumerKey");
                data.OAuthConsumerSecret = row.Field <string>("ConsumerSecret");
            }
            return(data);
        }
Beispiel #9
0
        public OAuthData GetOAuthData()
        {
            var oAuthData = new OAuthData();

            oAuthData.ClientId   = this.ClientId; //note: by default this is the NameId from the saml token
            oAuthData.ClientType = SamlOAuthClient.clientType;
            oAuthData.CommonName = this.CommonName;
            oAuthData.Email      = this.Email;
            oAuthData.UserName   = this.UserName;

            return(oAuthData);
        }
        public string GetSearch(OAuthData oAuthData)
        {
            var searchJson   = string.Empty;
            var authenticate = new Authenticate();
            TwitAuthenticateResponse twitAuthResponse = authenticate.AuthenticateMe(oAuthData.OAuthConsumerKey, oAuthData.OAuthConsumerSecret, OAuthUrl);

            // Do the timeline
            var utility = new Utility();

            searchJson = utility.RequstJson(searchUrl, twitAuthResponse.token_type, twitAuthResponse.access_token);

            return(searchJson);
        }
Beispiel #11
0
        public OAuthData GetOAuthData()
        {
            var oAuthData  = new OAuthData();
            var samlPlugin = PluginManager.GetSingleton <SamlOAuthClient>();

            oAuthData.ClientId   = this.ClientId; //note: by default this is the NameId from the saml token
            oAuthData.ClientType = samlPlugin.clientType;
            oAuthData.CommonName = this.CommonName;
            oAuthData.Email      = this.Email;
            oAuthData.UserName   = this.UserName;

            return(oAuthData);
        }
Beispiel #12
0
        private OAuthData ParseUserProfileInformation(dynamic repsonseJObject)
        {
            dynamic athlete = repsonseJObject.athlete;

            string clientUserId = athlete.id;

            var authData = new OAuthData();

            authData.ClientId   = clientUserId;
            authData.ClientType = ClientType;
            authData.Email      = athlete.email;
            authData.UserName   = GetUniquueUserName(athlete); //Note although this is called every time the user authenticates it's only used when the account is first created
            authData.AvatarUrl  = athlete.profile;
            authData.CommonName = athlete.firstname + athlete.lastname;

            return(authData);
        }
        public TwitterData GetMyTimeline(string url, OAuthData oAuthData)
        {
            timelineUrl = url;
            var authenticate = new Authenticate();
            TwitAuthenticateResponse twitAuthResponse = authenticate.AuthenticateMe(oAuthData.OAuthConsumerKey, oAuthData.OAuthConsumerSecret, OAuthUrl);

            // Do the timeline
            var timeLineJson = new Utility().RequstJson(timelineUrl, twitAuthResponse.token_type, twitAuthResponse.access_token);

            TwitterData response = new TwitterData();

            response.xmls = new List <XmlDocument>();

            if (timeLineJson.StartsWith("Error:"))
            {
                response.error = timeLineJson;
                return(response);
            }

            //List<XmlDocument> xmls = new List<XmlDocument>();

            if (timeLineJson == string.Empty || timeLineJson == "[]")
            {
                return(response);
            }

            timeLineJson = timeLineJson.Substring(3, timeLineJson.Length - 6);
            var timeLines = timeLineJson.Split(new [] { "\"},{\"" }, System.StringSplitOptions.None);

            try
            {
                foreach (string line in timeLines)
                {
                    response.xmls.Add(JsonConvert.DeserializeXmlNode("{\"root\":[{\"" + line + "\"}]}"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            return(response);
        }
Beispiel #14
0
        public static async Task <CgApiUser> GetUserByCredentials(CgApiUser.CgApiOauthCredentials credentials)
        {
            SettingsHolder.get_Settings().set_ENC_AuthToken(credentials.ToString());
            SettingsHolder.get_Settings().SaveSettingsAsync(false).ConfigureAwait(false);
            OAuthRequestInfos oAuthRequestInfos = OAuthData.GetOAuthRequestInfos();

            oAuthRequestInfos.UserKey    = credentials.get_Token();
            oAuthRequestInfos.UserSecret = credentials.get_TokenSecret();
            CgApiGlobalOAuthData.set_OAuthRequestInfos(oAuthRequestInfos);
            if (ObjectHolder.UserNotAuthorizedErrorHandler != null)
            {
                CgApiGlobalOAuthData.get_OAuthRequestInfos().UserNotAuthorizedErrorHandler = ObjectHolder.UserNotAuthorizedErrorHandler;
            }
            if (ObjectHolder.ServiceNotAvailablErrorHandler != null)
            {
                OAuthRequestInfos expr_84 = CgApiGlobalOAuthData.get_OAuthRequestInfos();
                expr_84.ServiceNotAvailablErrorHandler = (JsonOAuthRestClient.OnHttpErrorHandler)Delegate.Combine(expr_84.ServiceNotAvailablErrorHandler, ObjectHolder.ServiceNotAvailablErrorHandler);
            }
            CgApiUser cgApiUser = new CgApiUser(oAuthRequestInfos);
            CgApiUser result;

            try
            {
                await cgApiUser.Fetch();

                new CgApiUserCertificateManager().Fetch(cgApiUser.get_Token(), Constants.get_UserDataPath(), Constants.get_OpenVpnBinPath()).ConfigureAwait(false);
            }
            catch (WebException var_4_13F)
            {
                HelperFunctions.DebugLine("UNKNOWN WEBEXCEPTION IN GetUserByCredentials: " + var_4_13F.Message);
                result = null;
                return(result);
            }
            result = cgApiUser;
            return(result);
        }
        public void Init()
        {
            _createPositionMock = new Mock <IProcess <CreatePositionParams, PositionDisplayViewModel> >();
            _createPositionMock.Setup(x => x.Execute(It.IsAny <CreatePositionParams>())).Returns(new PositionDisplayViewModel());

            _verifyTokenMock = new Mock <IProcess <VerifyUserLinkedInAccessTokenParams, UserAccessTokenResultViewModel> >();
            _verifyTokenMock.Setup(x => x.Execute(It.IsAny <VerifyUserLinkedInAccessTokenParams>())).Returns(new UserAccessTokenResultViewModel {
                AccessTokenValid = true
            });

            _createCompanyCmdMock = CommandTestUtils.GenerateCreateCompanyCommandMock();
            _createCompanyCmdMock.Setup(x => x.Execute()).Returns(new Company {
                Id = NEW_COMPANY_ID
            });

            _companyQueryMock = QueryTestUtils.GenerateCompanyByIdQueryMock();
            _process          = new LinkedInPositionSearchProcesses(_context, _verifyTokenMock.Object, _createCompanyCmdMock.Object, _createPositionMock.Object, _companyQueryMock.Object);

            // Initialize user with test (but valid) access token data
            _user = new User {
                LastVisitedJobSearch = new JobSearch()
            };
            var oauth = new OAuthData
            {
                Token         = "bfcf3fe4-b4d4-4f37-9d32-292ae9d45347",
                Secret        = "f66673b2-5877-4fbf-80e0-3826ca9f7eed",
                TokenProvider = TokenProvider.LinkedIn,
                TokenType     = TokenType.AccessToken,
            };

            oauth.LinkedInUsers.Add(_user);
            _user.LinkedInOAuthData = oauth;
            _context.Users.Add(_user);
            _context.OAuthData.Add(oauth);
            _context.SaveChanges();
        }
        public void Token_Not_Valid_When_LinkedIn_Access_Token_Is_Invalid()
        {
            // Setup
            var oauth = new OAuthData
            {
                Token         = Guid.NewGuid().ToString(),
                Secret        = "f66673b2-5877-4fbf-80e0-3826ca9f7eed",
                TokenProvider = TokenProvider.LinkedIn,
                TokenType     = TokenType.AccessToken
            };

            _context.OAuthData.Add(oauth);
            _user.LinkedInOAuthData = oauth;
            _context.SaveChanges();

            // Act
            var result = _process.Execute(new VerifyUserLinkedInAccessTokenParams {
                UserId = _user.Id
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsFalse(result.AccessTokenValid, "Process incorrectly specified the access token as valid");
        }
        public void Token_Is_Valid_After_LinkedIn_Validation()
        {
            // Setup
            var oauth = new OAuthData
            {
                Token         = "bfcf3fe4-b4d4-4f37-9d32-292ae9d45347",
                Secret        = "f66673b2-5877-4fbf-80e0-3826ca9f7eed",
                TokenProvider = TokenProvider.LinkedIn,
                TokenType     = TokenType.AccessToken
            };

            _context.OAuthData.Add(oauth);
            _user.LinkedInOAuthData = oauth;
            _context.SaveChanges();

            // Act
            var result = _process.Execute(new VerifyUserLinkedInAccessTokenParams {
                UserId = _user.Id
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(result.AccessTokenValid, "Process incorrectly specified the access token as not valid");
        }
Beispiel #18
0
 private void Load()
 {
     _data   = OAuthData.Serializer.Load(_config.DataDirectory);
     _client = new Lazy <OAuthClient>(LoadClient);
 }
 protected override void AuthDataDeserializeImpl(string content)
 {
     m_authData = OAuthData.Deserialize(content);
 }
        private OAuthData ParseUserProfileInformation(dynamic repsonseJObject)
        {
            dynamic athlete = repsonseJObject.athlete;

            string clientUserId = athlete.id;

            var authData = new OAuthData();
   
            authData.ClientId = clientUserId;
            authData.ClientType = ClientType;
            authData.Email = athlete.email;
            authData.UserName = GetUniquueUserName(athlete);  //Note although this is called every time the user authenticates it's only used when the account is first created
            authData.AvatarUrl = athlete.profile;
            authData.CommonName = athlete.firstname + athlete.lastname;
         
            return authData;
        }
Beispiel #21
0
        public OAuthData GetOAuthData()
        {
            var oAuthData = new OAuthData();

            oAuthData.ClientId = this.Email;
            oAuthData.ClientType = SamlOAuthClient.clientType;
            oAuthData.CommonName = this.CommonName;
            oAuthData.Email = this.Email;
            oAuthData.UserName = this.UserName;

            return oAuthData;
        }
        public bool Authenticate(HttpRequestMessage request)
        {
            if (m_authFlow != AuthFlow.Obtained)
            {
                var                host          = GetHost(request.RequestUri.AbsoluteUri);
                var                authUriString = $"{host}/oauth2/token";
                HttpClient         authClient    = new HttpClient();
                HttpRequestMessage authReq       = new HttpRequestMessage()
                {
                    RequestUri = new Uri(authUriString),
                    Method     = HttpMethod.Post
                };
                authReq.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                authReq.Headers.Add("ContentType", "application/x-www-form-urlencoded");
                List <KeyValuePair <string, string> > authReqContent;
                switch (m_authFlow)
                {
                case AuthFlow.ObtainAccessTokenPending:
                    authReqContent = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("grant_type", "client_credentials"),
                        new KeyValuePair <string, string>("client_id", m_ClientId),
                        new KeyValuePair <string, string>("client_secret", m_ClientSecret)
                    };

                    break;

                case AuthFlow.RefreshAccessTokenPending:

                    if (m_authData == null)
                    {
                        throw new Exception($"Wrong OAuth2 flow");
                    }

                    authReqContent = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("grant_type", "refresh_token"),
                        new KeyValuePair <string, string>("refresh_token", m_authData.RefreshToken)
                    };
                    break;

                default:
                    throw new Exception($"Wrong OAuth2 flow");
                }
                authReq.Content = new FormUrlEncodedContent(authReqContent);

                var authResponse = authClient.SendAsync(authReq).Result;
                if (authResponse.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var content = authResponse.Content.ReadAsStringAsync().Result;
                    m_authData = OAuthData.Deserialize(content);
                    m_authFlow = AuthFlow.Obtained;
                }
            }

            if (m_authData != null)
            {
                if (m_authData.HasError)
                {
                    throw new Exception($"OAuth 2.0: Authentication error: {m_authData.Error}", new Exception(m_authData.ErrorDescription));
                }
                request.Headers.Add("Authorization", AuthorizationHeaderValue);
            }
            return(true);
        }
Beispiel #23
0
        private async Task <T> RefreshAuthorization <T>(Func <CancellationToken, OAuthData, Task <T> > func, OAuthData authenticationData, CancellationToken ct)
        {
            try
            {
                var refreshedAuthData = await _oAuthClient.RefreshToken(authenticationData.RefreshToken, ct);

                lock (_lock)
                {
                    _secureStorage.SetValue(StorageKey, refreshedAuthData.Auth);
                }

                return(await func(ct, refreshedAuthData.Auth));
            }
            catch (UnauthorizedAccessException ex)
            {
                InternalLogout(ex);
            }

            return(default);
Beispiel #24
0
        public static async Task <CgApiUser> GetNewAutoCreatedUser()
        {
            int       num;
            CgApiUser result;
            CgApiUser cgApiUser;

            if (num > 1)
            {
                if (Theming.CurrentTheme == Theming.Theme.Pro)
                {
                    result = null;
                    return(result);
                }
                cgApiUser = new CgApiUser(OAuthData.GetOAuthRequestInfos());
            }
            try
            {
                TaskAwaiter <CgApiUser.CgApiOauthCredentials> var_4 = cgApiUser.CreateUserAndGetCredentials(OAuthInfos.ClientId, SettingsHolder.get_Settings().get_Language(), null, null).GetAwaiter();
                if (!var_4.IsCompleted)
                {
                    await var_4;
                    TaskAwaiter <CgApiUser.CgApiOauthCredentials> taskAwaiter;
                    var_4       = taskAwaiter;
                    taskAwaiter = default(TaskAwaiter <CgApiUser.CgApiOauthCredentials>);
                }
                CgApiUser.CgApiOauthCredentials arg_D0_0 = var_4.GetResult();
                var_4 = default(TaskAwaiter <CgApiUser.CgApiOauthCredentials>);
                CgApiUser.CgApiOauthCredentials cgApiOauthCredentials = arg_D0_0;
                if (cgApiOauthCredentials == null)
                {
                    result = null;
                    return(result);
                }
                SettingsHolder.get_Settings().set_ENC_AuthToken(cgApiOauthCredentials.ToString());
                SettingsHolder.get_Settings().SaveSettingsAsync(false).ConfigureAwait(false);
                OAuthRequestInfos oAuthRequestInfos = OAuthData.GetOAuthRequestInfos();
                oAuthRequestInfos.UserKey    = cgApiOauthCredentials.get_Token();
                oAuthRequestInfos.UserSecret = cgApiOauthCredentials.get_TokenSecret();
                CgApiGlobalOAuthData.set_OAuthRequestInfos(oAuthRequestInfos);
                cgApiUser = new CgApiUser(oAuthRequestInfos);
                ConfiguredTaskAwaitable <bool> .ConfiguredTaskAwaiter var_5 = cgApiUser.Fetch().ConfigureAwait(false).GetAwaiter();
                if (!var_5.IsCompleted)
                {
                    await var_5;
                    ConfiguredTaskAwaitable <bool> .ConfiguredTaskAwaiter configuredTaskAwaiter;
                    var_5 = configuredTaskAwaiter;
                    configuredTaskAwaiter = default(ConfiguredTaskAwaitable <bool> .ConfiguredTaskAwaiter);
                }
                var_5.GetResult();
                var_5 = default(ConfiguredTaskAwaitable <bool> .ConfiguredTaskAwaiter);
                new CgApiUserCertificateManager().Fetch(cgApiUser.get_Token(), Constants.get_UserDataPath(), Constants.get_OpenVpnBinPath()).ConfigureAwait(false);
                if (ObjectHolder.UserNotAuthorizedErrorHandler != null)
                {
                    CgApiGlobalOAuthData.get_OAuthRequestInfos().UserNotAuthorizedErrorHandler = ObjectHolder.UserNotAuthorizedErrorHandler;
                }
                if (ObjectHolder.ServiceNotAvailablErrorHandler != null)
                {
                    OAuthRequestInfos expr_1CE = CgApiGlobalOAuthData.get_OAuthRequestInfos();
                    expr_1CE.ServiceNotAvailablErrorHandler = (JsonOAuthRestClient.OnHttpErrorHandler)Delegate.Combine(expr_1CE.ServiceNotAvailablErrorHandler, ObjectHolder.ServiceNotAvailablErrorHandler);
                }
            }
            catch (WebException var_7_1EA)
            {
                HelperFunctions.DebugLine("UNKNOWN WEBEXCEPTION IN GetNewAutoCreatedUser: " + var_7_1EA.Message);
                result = null;
                return(result);
            }
            result = cgApiUser;
            return(result);
        }