Example #1
0
        public void CheckToken(string token, CheckTokenCallback callback)
        {
            if (!Syncing)
            {
                Authentication authentication = new Authentication(new RawAuthentication()
                {
                    Permissions = AuthenticationPermissions.Delete,
                    Token = string.Empty,
                    User = new RawUser() { Id = RtmElement.UnsyncedId, UserName = "******", FullName = "IronCow is currently disabled" }
                });
                callback(authentication, true);
            }
            else
            {

                Dictionary<string, string> parameters = new Dictionary<string, string>();
                parameters.Add("auth_token", token);

                GetResponse("rtm.auth.checkToken", parameters, false, (response) =>
                {
                    if (response.Status == ResponseStatus.OK)
                    {
                        Authentication authentication = new Authentication(response.Authentication);
                        callback(authentication, true);
                    }
                    else
                    {
                        Authentication authentication = null;
                        if (response.Error.Code == ErrorCode.LoginFailedOrInvalidAuthToken)
                        {
                            callback(authentication, true);
                        }
                        else
                        {
                            throw new RtmException(response.Error);
                        }
                    }
                });
            }
        }
Example #2
0
        public void CheckToken(string token, CheckTokenCallback callback)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("auth_token", token);

            GetResponse("rtm.auth.checkToken", parameters, false, (response) =>
            {
                if (response.Status == ResponseStatus.OK)
                {
                    callback(response.Authentication, true);
                }
                else
                {
                    if (response.Error.Code == ErrorCode.LoginFailedOrInvalidAuthToken)
                        callback(null, false);
                    else
                        throw new RtmException(response.Error);
                }
            });
        }