def get_token(code, scope='user'): """Request a token from the Slack API.""" # Set OAuth access object oauth = OAuth() # Setup return URL return_url = '{0}_url'.format(scope) try: # Attempt to make request result = oauth.access(client_id=PROJECT_INFO['client_id'], client_secret=PROJECT_INFO['client_secret'], redirect_uri=PROJECT_INFO[return_url], code=code) except Error as err: report_event('oauth_error', { 'code': code, 'return_url': return_url, 'error': str(err) }) abort(400) if not result.successful: report_event('oauth_unsuccessful', { 'code': code, 'return_url': return_url, 'result': result.__dict__ }) abort(400) # Return token return result.body['access_token']
def get_token(code): """Request a token from the Slack API.""" # Set OAuth access object oauth = OAuth() try: # Attempt to make request result = oauth.access(client_id=PROJECT_INFO['client_id'], client_secret=PROJECT_INFO['client_secret'], redirect_uri=PROJECT_INFO['valid_url'], code=code) except Error as err: report_event('oauth_error', {'code': code, 'error': str(err)}) abort(400) if not result.successful: report_event('oauth_unsuccessful', { 'code': code, 'result': result.__dict__ }) abort(400) # Setup return info info = { 'token': result.body['access_token'], 'team_id': result.body['team_id'], 'bot_id': result.body['bot']['bot_user_id'], 'bot_token': result.body['bot']['bot_access_token'] } # Return info return info
def get_token(code, scope='user'): ''' Requests a token from the Slack API ''' # Set OAuth access object oauth = OAuth() # Setup return URL return_url = '{0}_url'.format(scope) try: # Attempt to make request result = oauth.access( client_id=PROJECT_INFO['client_id'], client_secret=PROJECT_INFO['client_secret'], redirect_uri=PROJECT_INFO[return_url], code=code ) except Error: abort(400) if not result.successful: abort(400) # Return token return result.body['access_token']
def get_token(code, scope="user"): """Request a token from the Slack API.""" # Set OAuth access object oauth = OAuth() # Setup return URL return_url = "{0}_url".format(scope) try: # Attempt to make request result = oauth.access( client_id=PROJECT_INFO["client_id"], client_secret=PROJECT_INFO["client_secret"], redirect_uri=PROJECT_INFO[return_url], code=code, ) except Error as err: report_event("oauth_error", {"code": code, "return_url": return_url, "error": str(err)}) abort(400) if not result.successful: report_event("oauth_unsuccessful", {"code": code, "return_url": return_url, "result": result.__dict__}) abort(400) # Return token return result.body["access_token"]
def get_token(code): """Request a token from the Slack API.""" # Set OAuth access object oauth = OAuth() try: # Attempt to make request result = oauth.access( client_id=PROJECT_INFO['client_id'], client_secret=PROJECT_INFO['client_secret'], redirect_uri=PROJECT_INFO['valid_url'], code=code ) except Error as err: report_event('oauth_error', { 'code': code, 'error': str(err) }) abort(400) if not result.successful: report_event('oauth_unsuccessful', { 'code': code, 'result': result.__dict__ }) abort(400) # Setup return info info = { 'token': result.body['access_token'], 'team_id': result.body['team_id'], 'bot_id': result.body['bot']['bot_user_id'], 'bot_token': result.body['bot']['bot_access_token'] } # Return info return info
def get_token(code): """Request a token from the Slack API.""" oauth = OAuth() result = None try: # Attempt to make request result = oauth.access( client_id=project_info['client_id'], client_secret=project_info['client_secret'], redirect_uri=project_info['valid_url'], code=code ) except Error as err: report_event('oauth_error', { 'code': code, 'error': str(err) }) abort(400) if not result or not result.successful: report_event('oauth_unsuccessful', { 'code': code, 'result': result.__dict__ }) abort(400) # Setup return info info = { 'team_id': result.body['team_id'], 'channel_id': result.body['incoming_webhook']['channel_id'], 'url': result.body['incoming_webhook']['url'] } # Return info return info