Example #1
0
 /// <summary>
 /// Notify SDK that user denied login
 /// </summary>
 /// <param name="error">Description of error while authorizing user</param>
 public static void SetAccessTokenError(VKError error)
 {
     AccessDenied(null, new VKAccessDeniedEventArgs { AuthorizationError = error });
 }
Example #2
0
        private bool PerformTokenCheck(VKAccessToken token, bool isUserDefinedToken = false)
        {
            if (token == null) return false;

            if (token.IsExpired)
            {
                AccessTokenExpired(null, new VKAccessTokenExpiredEventArgs { ExpiredToken = token });
                return false;
            }
            if (token.AccessToken != null)
            {
                if (isUserDefinedToken)
                    AccessTokenAccepted(null, new VKAccessTokenAcceptedEventArgs { Token = token });
                return true;
            }

            var error = new VKError { error_code = (int)VKResultCode.InvalidToken };
            AccessDenied(null, new VKAccessDeniedEventArgs { AuthorizationError = error });
            return false;
        }
Example #3
0
        /// <summary>
        /// Check new access token and assign as instance token 
        /// </summary>
        /// <param name="tokenParams">Params of token</param>
        /// <param name="isTokenBeingRenewed">Flag indicating token renewal</param>
        /// <returns>Success if token has been assigned or error</returns>
        private static CheckTokenResult CheckAndSetToken(Dictionary<String, String> tokenParams, bool isTokenBeingRenewed)
        {
            var token = VKAccessToken.TokenFromParameters(tokenParams);
            if (token == null || token.AccessToken == null)
            {
                if (tokenParams.ContainsKey(VKAccessToken.SUCCESS))
                    return CheckTokenResult.Success;

                var error = new VKError { error_code = (int)VKResultCode.UserAuthorizationFailed };

                return CheckTokenResult.Error;
            }
            else
            {
                SetAccessToken(token, isTokenBeingRenewed);
                return CheckTokenResult.Success;
            }


        }