[program-l] Re: python and flask

  • From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx, Juan Hernandez <juanhernandez98@xxxxxxxxx>
  • Date: Thu, 15 Nov 2018 23:58:49 -0500

Hello,
If this is local, you'll probably be better off bundling a small
webserver like tornado maybe?
Flask does have a server, but it's mostly only for debugging and testing.
HTH,

On 11/15/2018 9:28 PM, Juan Hernandez wrote:


Hi All,

 

I’m developing an alternative slack client that is far more accessible
than the slack client that is released directly by slack.

 

One issue I’m having and this just because I haven’t done much in the
past with Flask, is the instructions say to create a web server using
flask for slack.

 

Here is the instructions at: 
https://slackapi.github.io/python-slackclient/auth.html

 

Now, here is my webserver.py file :

 

# controler / webserver.py

 

importos

fromflaskimportFlask, request

fromslackclientimportSlackClient

importcontroler.configascfg

 

app_oauth_scopes = [

    "client",

    "channels:read",

    "channels:write",

    "channels:history",

    "chat:read:user",

    "chat:write:user",

    "dnd:read",

    "dnd:write",

    "dnd:write:user",

    "emoji:read",

    "groups:history",

    "groups:read",

    "groups:write",

    "identity.basic",

    "identity.basic:user",

    "im:history",

    "im:read",

    "im:write",

    "team:read",

    ]

 

client_id = cfg.slack_client_id

client_secret = cfg.slack_client_secret

 

app = Flask(__name__)

 

@app.route("/begin_auth", methods=["GET"])

defpreinstall():

    return'''

        <a
href="https://slack.com/oauth/authorize?scope={0}&client_id={1}";>Sign
In to Slack</a>

        '''.format(app_oauth_scopes, client_id)

 

        # end function begin_oauth

 

@app.route("/finish_auth", methods=["GET", "POST"])

defpostinstall():

 

    # Retrieve the auth code from the request params

    auth_code = request.args['code']

 

    # An empty string is a valid token for this request

    sc = SlackClient("")

 

    # Request the auth tokens from Slack

    auth_response = sc.api_call(

        "oauth.access",

        client_id=client_id,

        client_secret=client_secret,

        code=auth_code

    )

 

    returnauth_response

 

can someone please explain how this is to be used? In the past I’ve
seen that applications launch a web browser, with a sign into slack
button, and then it takes mme to slack.  How can I duplicate this
process? How is this webserver used?  This is frustrating as my slack
client is starting to come together.  I’m testing with a ttest token,
and now I want to release it to a test group so they can try it out.

 

Thanks for any help.

 

 

 

 


-- 

Take Care,
Tyler Littlefield

Tyler Littlefield Consulting: website development and business
solutions. <http://tylerlittlefield.me> My personal site
<http://tysdomain.com> My Linkedin
<https://www.linkedin.com/in/ty-lerlittlefield> @Sorressean on Twitter
<http://twitter.com/sorressean>

Other related posts: