[program-l] Re: python and flask

  • From: Taksan <taksantong@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Fri, 16 Nov 2018 17:55:51 -0300

have you seen this tutorial on python+slack?

https://www.fullstackpython.com/blog/build-first-slack-bot-python.html

looks like they don't need flask or a webpage...

On 11/16/18, Jim Homme <jhomme@xxxxxxxxxxxxxxxxx> wrote:

Hi,
I have not looked into this, but sometime back someone recommended cef
Python. That's c e f Python. It embeds the Chrome framework. You might want
to google it.

Thanks.

Jim



==========
Jim Homme
Product Manager
Digital Accessibility
Bender Consulting Services
412-787-8567
https://www.benderconsult.com/our%20services/hightest-accessible-technology-solutions
People with disabilities, access job openings at
https://www.benderconsult.com/careers/job-openings


From: program-l-bounce@xxxxxxxxxxxxx <program-l-bounce@xxxxxxxxxxxxx> On
Behalf Of Littlefield, Tyler
Sent: Thursday, November 15, 2018 11:59 PM
To: program-l@xxxxxxxxxxxxx; Juan Hernandez <juanhernandez98@xxxxxxxxx>
Subject: [program-l] Re: python and flask

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

import os
from flask import Flask, request
from slackclient import SlackClient
import controler.config as cfg

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:history>,
    "im:read"<im:read>,
    "im:write"<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"])
def preinstall():
    return '''
        <a
href="https://slack.com/oauth/authorize?scope={0}&client_id={1}";<https://slack.com/oauth/authorize?scope=%7b0%7d&client_id=%7b1%7d>>Sign
In to Slack</a>
        '''.format(app_oauth_scopes, client_id)

        # end function begin_oauth

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

    # 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
    )

    return auth_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>

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: