Performs a validation of the given token and returns its payload
        dictionary.

        Raises a `TokenBackendError` if the token is malformed, if its
        signature check fails, or if its 'exp' claim indicates it has expired.
163129
def decode(self, token, verify=True):
        
        try:
            return jwt.decode(token, self.verifying_key, algorithms=[self.algorithm], verify=verify)
        except InvalidTokenError:
            raise TokenBackendError(_('Token is invalid or expired'))
673073
def _token_valid(self):
        
        if not self._cache_token:
            return False
        now = time.time()
        if now - self._token.acquired_time > self._token_timeout:
            logger.debug('token needs to be reset')
            return False
        return True
1156080
function validateToken(bearerToken) {
    var validatedToken = bearerToken;
    if (bearerToken.startsWith('bearer ')) {
        validatedToken = bearerToken.replace('bearer ', '');
    }
    return validatedToken;
}
1195036
def parse_token(self, token):
        
        try:
            data = self.unsign(token)
        except signing.SignatureExpired:
            logger.debug("Expired token: %s", token)
            return
        except signing.BadSignature:
            logger.debug("Bad token: %s", token)
            return
        except Exception:
            logger.exception(
                "Valid signature but unexpected token - if you changed "
                "django-sesame settings, you must regenerate tokens")
            return
        user_pk, data = self.packer.unpack_pk(data)
        user = self.get_user(user_pk)
        if user is None:
            logger.debug("Unknown token: %s", token)
            return
        h = crypto.pbkdf2(
            self.get_revocation_key(user),
            self.salt,
            self.iterations,
            digest=self.digest,
        )
        if not crypto.constant_time_compare(data, h):
            logger.debug("Invalid token: %s", token)
            return
        logger.debug("Valid token for user %s: %s", user, token)
        return user
1017754
def verify_token(token)
        logger.debug("Verifying token: #{token}")

        # First get the payload of the token. This will also verify whether
        # or not the token is welformed.
        payload = get_token_payload(token)

        # Next, the payload should define user UUID and session UUID.
        user_uuid = payload["user_uuid"]
        session_uuid = payload["session_uuid"]
        if user_uuid.nil? || session_uuid.nil?
          logger.error("User or session is not specified")
          raise UNAUTHORIZED_ERROR, "Invalid token"
        end
        logger.debug("Token well defined: #{token}")

        # But, the user UUID and session UUID better be valid too. That is,
        # they must be real user and session, and the session must belong to
        # the user.
        auth_user = User.find_by_uuid(user_uuid)
        if auth_user.nil?
          # :nocov:
          logger.error("Specified user doesn't exist #{user_uuid}")
          raise UNAUTHORIZED_ERROR, "Invalid token"
          # :nocov:
        end
        auth_session = Session.find_by_uuid(session_uuid)
        if auth_session.nil? || auth_session.user != auth_user
          logger.error("Specified session doesn't exist #{session_uuid}")
          raise UNAUTHORIZED_ERROR, "Invalid token"
        end

        # Finally, decode the token using the secret. Also check expiration
        # here too.
        JWT.decode token, auth_session.secret, true
        logger.debug("Token well formatted and verified. Set cache.")

        # Return the corresponding session
        return auth_session

      rescue JWT::DecodeError => e
        logger.error(e.message)
        raise UNAUTHORIZED_ERROR, "Invalid token"
      end
422370
def check_token(token: str) -> bool:
    
    if any(x.isspace() for x in token):
        raise exceptions.ValidationError('Token is invalid!')

    left, sep, right = token.partition(':')
    if (not sep) or (not left.isdigit()) or (len(left) < 3):
        raise exceptions.ValidationError('Token is invalid!')

    return True
734043
def contains(self, token: str) -> bool:
        """"""
        self._validate_token(token)
        return token in self
314574
def check_token(self, token=None):
        
        if token is None:
            token = self.token
        resp, resp_body = self.method_head("tokens/%s" % token, admin=True)
        if resp.status_code in (401, 403):
            raise exc.AuthorizationFailure("You must be an admin to make this "
                    "call.")
        return 200 <= resp.status_code < 300
832416
def check_input(self, token):
        
        if token is None:
            raise Exception(self.full_name + ": No token provided!")
        if not isinstance(token.payload, Instances):
            raise Exception(self.full_name + ": Not an Instances object!")
289700
def validate_recovery_token!(token, context = {})
      errors = []

      # 1. Authenticate the User. The exact nature of how the Recovery Provider authenticates the User is beyond the scope of this specification.
      # handled in before_filter

      # 4. Retrieve the Account Provider configuration as described in Section 2 using the issuer field of the token as the subject.
      begin
        account_provider = RecoveryToken.account_provider_issuer(token)
      rescue RecoveryTokenSerializationError, UnknownProviderError, TokenFormatError => e
        raise RecoveryTokenError, "Could not determine provider: #{e.message}"
      end

      # 2. Parse the token.
      # 3. Validate that the version value is 0.
      # 5. Validate the signature over the token according to processing rules for the algorithm implied by the version.
      begin
        recovery_token = account_provider.unseal(token, context)
      rescue CryptoError => e
        raise RecoveryTokenError.new("Unable to verify signature of token")
      rescue TokenFormatError => e
        raise RecoveryTokenError.new(e.message)
      end

      # 6. Validate that the audience field of the token identifies an origin which the provider considers itself authoritative for. (Often the audience will be same-origin with the Recovery Provider, but other values may be acceptable, e.g. "https://mail.example.com" and "https://social.example.com" may be acceptable audiences for "https://recovery.example.com".)
      unless self.origin == recovery_token.audience
        raise RecoveryTokenError.new("Unnacceptable audience")
      end

      if DateTime.parse(recovery_token.issued_time).utc < (Time.now - CLOCK_SKEW).utc
        raise RecoveryTokenError.new("Issued at time is too far in the past")
      end

      recovery_token
    end
490895
def validate_request(self, request):
        
        token = get_token_from_header(request)
        return self.request_validator.validate_bearer_token(
            token, request.scopes, request)
270985
public final void validateExpiration() throws TokenExpiredException {
        Date d = new Date();
        Date expD = new Date(getExpiration());
        boolean expired = d.after(expD);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "Current time = " + d + ", expiration time = " + expD);
        }
        if (expired) {
            String msg = "The token has expired: current time = \"" + d + "\", expire time = \"" + expD + "\"";
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(this, tc, msg);
            }
            throw new TokenExpiredException(expirationInMilliseconds, msg);
        }
    }
211819
def validate_token_age(callback_token):
    
    try:
        token = CallbackToken.objects.get(key=callback_token, is_active=True)
        seconds = (timezone.now() - token.created_at).total_seconds()
        token_expiry_time = api_settings.PASSWORDLESS_TOKEN_EXPIRE_TIME

        if seconds <= token_expiry_time:
            return True
        else:
            # Invalidate our token.
            token.is_active = False
            token.save()
            return False

    except CallbackToken.DoesNotExist:
        # No valid token.
        return False
988809
def verify_token(self, token):
        '''
        
        '''
        try:
            result = self.resolver.get_token(token)
        except Exception as ex:
            raise EauthAuthenticationError(
                "Token validation failed with {0}.".format(repr(ex)))

        return result
800339
function validateToken (token) {
  const header = jwt.decode(token)
  const now = Math.floor(Date.now() / 1000)
  return header && header.exp > now
}
5457
def get_instance(self, payload):
        
        return TokenInstance(self._version, payload, account_sid=self._solution['account_sid'], )
875336
def is_expired(self, token, when=0):
        
        verifier = JWT(key_jar=self.key_jar, allowed_sign_algs=[self.alg])
        _payload = verifier.unpack(token)
        return is_expired(_payload['exp'], when)