Egg_mode 401 unauthorized when trying to bind to twitter stream

Hi I'm trying to use the egg_mode crate to retrieve a stream of tweets as per the example here: but with just a slight difference in the way I input my token.

async fn main() {

    let con_token = egg_mode::KeyPair::new(CONSUMER_KEY, CONSUMER_SECRET);

    println!("Live streaming tweets...");

    println!("Ctrl-C to quit\n");

    let stream = egg_mode::stream::filter()
        .try_for_each(|m| {
            if let StreamMessage::Tweet(tweet) = m {
           } else {
    if let Err(e) = stream.await {
        println!("Stream error: {}", e);

However I keep getting a 401 unauthorized error.

Using the same bearer token, I am able to retrieve tweets with no problem using egg_mode::tweet::user_timeline as per the example here:

What could be the problem?

I've found a workaround by using the Access variant of the Token enum instead of the Bearer variant. When I do this it works.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.