Skip to content

Getting 401 unauthorized when requesting stream filter #109

@egithinji

Description

@egithinji

I'm using the example here: https://github.com/egg-mode-rs/egg-mode/blob/master/examples/stream_filter.rs
Just that I'm entering my token differently in the start function. The same token works fine when fetching tweets using egg_mode::tweet::user_timeline. But when fetching the stream I get 401 unauthorized.

Am I doing something wrong?

`#[tokio::main]
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()
    .track(&["rustlang"])
    .start(&Token::Bearer(BEARERTOKEN.to_string()))
    .try_for_each(|m| {
        if let StreamMessage::Tweet(tweet) = m {
            println!("{}\n{}",tweet.created_at,tweet.text);
       } else {
            println!("{:?}",m);
        }
        futures::future::ok(())
    });
if let Err(e) = stream.await {
    println!("Stream error: {}", e);
    println!("Disconnected")
}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions