Example #1
0
        public static Uri GetAuthorizeUri(string clientId, SlackScope scopes, string redirectUri = null, string state = null, string team = null)
        {
            string theScopes = BuildScope(scopes);

            return(GetSlackUri("https://slack.com/oauth/authorize", new Tuple <string, string>[] { new Tuple <string, string>("client_id", clientId),
                                                                                                   new Tuple <string, string>("redirect_uri", redirectUri),
                                                                                                   new Tuple <string, string>("state", state),
                                                                                                   new Tuple <string, string>("scope", theScopes),
                                                                                                   new Tuple <string, string>("team", team) }));
        }
Example #2
0
        private static string BuildScope(SlackScope scope)
        {
            var builder = new StringBuilder();

            if ((int)(scope & SlackScope.Identify) != 0)
            {
                builder.Append("identify");
            }
            if ((int)(scope & SlackScope.Read) != 0)
            {
                if (builder.Length > 0)
                {
                    builder.Append(",");
                }
                builder.Append("read");
            }
            if ((int)(scope & SlackScope.Post) != 0)
            {
                if (builder.Length > 0)
                {
                    builder.Append(",");
                }
                builder.Append("post");
            }
            if ((int)(scope & SlackScope.Client) != 0)
            {
                if (builder.Length > 0)
                {
                    builder.Append(",");
                }
                builder.Append("client");
            }
            if ((int)(scope & SlackScope.Admin) != 0)
            {
                if (builder.Length > 0)
                {
                    builder.Append(",");
                }
                builder.Append("admin");
            }

            return(builder.ToString());
        }
Example #3
0
 public static Uri GetAuthorizeUri(string clientId, SlackScope scopes, string redirectUri = null, string state = null, string team = null)
 {
     return(GetAuthorizeUri(clientId, BuildScope(scopes), redirectUri, state, team));
 }