예제 #1
0
파일: VKSDK.cs 프로젝트: orinichevd/BVk
 /// <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 });
 }
예제 #2
0
파일: VKSDK.cs 프로젝트: orinichevd/BVk
        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;
        }
예제 #3
0
파일: VKSDK.cs 프로젝트: orinichevd/BVk
        /// <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;
            }


        }