slack-rs / slack-rs-api

Rust interface for the Slack Web API
Apache License 2.0
110 stars 67 forks source link

Slack App with a bot user token throws "Missing Scope" error #100

Closed ArulselvanMadhavan closed 4 years ago

ArulselvanMadhavan commented 4 years ago

Thanks for writing this library. I'm trying to use this library for building a feature at work. What I'm testing is a simple use case. Post a message to a channel

    let response = slack::chat::post_message(
        &client,
        &token,
        &slack::chat::PostMessageRequest {
            channel: &channel_id,
            text: "Sample Message",
            ..slack::chat::PostMessageRequest::default()
        },
    )
    .await;

I'm initiating the client and setting up the token, the way it's shown in the example

    let token = env::var("SLACK_API_TOKEN").map_err(|_| "SLACK_API_TOKEN env var must be set")?;
    println!("TOKEN{:?}", token);
    let client = slack::default_client().map_err(|_| "Could not get default_client")?;
    let channel_id = env::args()
        .nth(1)
        .ok_or("must specify channel id as argument e.g. C09123456")?;

I get an error saying "Missing scope" in the response. I'm not sure where I can pass a scope as part of the authorization request. I found out that someone had run into somewhat similar issue with rtm and also the channel::history is now obsolete. I'd be happy to contribute an updated/working example, if I figure this out.

Cheers!

dten commented 4 years ago

sounds the same as #77 slack uses oauth for permissions and the auth token you've created does not have the required scopes granted by slack. there's explanation and link to the docs in that issue

ArulselvanMadhavan commented 4 years ago

Thanks @dten! This helped. Closing the issue