Inumedia / SlackAPI

.NET Implementation of the Slack team communication platform API.
MIT License
452 stars 243 forks source link

Documentation outdated not working example for SlackClient.StartAuth and AuthSignin #213

Closed LazaroOnline closed 4 years ago

LazaroOnline commented 4 years ago

From the project's README.md there is a link to the code examples at: https://github.com/Inumedia/SlackAPI/wiki/Examples

The very first example of how to connect using user/password combination instead of tokens doesn't compile with the last version of the library from NuGet.

this is the example in documentation:

SlackClient.StartAuth((authStartResponse) =>{
    // Here authStartResponse has a field ('users') containing a list of teams you have access to.
    SlackClient.AuthSignin(
        (authSigninResponse) =>{
            //Here, authSigninResponse contains a field 'token' which is your valid authentication token.
        }, 
        authStartResponse.users[0].user_id, 
        authStartResponse.users[1].team_id, 
        YOUR_PASSWORD_HERE
    );
}, YOUR_EMAIL_HERE);

The methods SlackClient.StartAuth and SlackClient.AuthSignin are not found in the class definition.

Can you update the doc with a working example for the Auth login? Thank you very much!

jculverwell commented 4 years ago

Please find some instructions I put together today which worked great. This is the first time I've used this project so the instructions might need improving.

Configuring Slack

1) Goto https://api.slack.com/apps 2) Click create app 3) Give the app a name and assign it to a workspace 4) Click OAuth & Permissions (In the left hand menu) 5) Under Scopes click Add an OAuth Scope and select chat:write:bot 6) At the top click Install App to workspace 7) Click Allow 8) Copy the OAuth Access Token (top of the page). This is the token you need to pass into the Slack Client.

Running the code

1) Install-Package SlackAPI 2) Your code should look similar to this:

public static async Task Main(string[] args)
{
  const string TOKEN = "YOUR TOKEN HERE";  // token from last step in section above
  var slackClient = new SlackTaskClient(TOKEN);
  //check you are posting to the right channel
  var response = await slackClient.PostMessageAsync("#general", "hello world");
  //check the response above if its not working for you
}
gpailler commented 4 years ago

Hi @jculverwell Thanks a lot for your steps, I updated the Example page according to your instructions https://github.com/Inumedia/SlackAPI/wiki/Examples