Can't connect with upwork to get any information

一世执手 提交于 2020-01-23 17:14:27

问题


I try to use upwork api in flask to get some information, but it doesn't work. How could I get something from upwork with its api?

file app.py

import os
from flask import *
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
from config import Configuration
from upwork import *
import upwork


# Create Flask app
app = Flask(__name__)
app.config.from_object(Configuration)
db = SQLAlchemy(app)
conn = db.engine
#os.environ['HTTPLIB_CA_CERTS_PATH'] = app.config.get('PATH_PEM')

# Create Migration db
migrate = Migrate(app, db, compare_type=True)
manager = Manager(app)
manager.add_command('db', MigrateCommand)

UP_PUBLIC_KEY = app.config.get('UP_PUBLIC_KEY')
UP_SECRET_KEY = app.config.get('UP_SECRET_KEY')
UP_ACCESS_TOKEN = app.config.get('UP_ACCESS_TOKEN')
UP_ACCEES_TOKEN_SECRET = app.config.get('UP_ACCEES_TOKEN_SECRET')

file view.py:

from app import *


@app.route('/')
def get_from_api():
    client = upwork.Client(UP_PUBLIC_KEY, UP_SECRET_KEY)
    client = upwork.Client(UP_PUBLIC_KEY, UP_SECRET_KEY, oauth_access_token=UP_ACCESS_TOKEN,
                           oauth_access_token_secret=UP_ACCEES_TOKEN_SECRET)
    request_token = client.auth.get_request_token()
    print(request_token)
    pass

When I call "print(request_token)" it prints "null:null"


回答1:


please,

  1. check the code in view.py: you redefine client with an access token/secret which doesn't exist (judging by what you describe). As a result, you get 404 for non-existing token-secret pair.

  2. check the documentation at http://upwork.github.io/python-upwork/getting_started.html#simple-example

  3. try to implement a simple request using the only python-upwork library and only after that move the code under the flask, to avoid any unexpected behavior in your code.



来源:https://stackoverflow.com/questions/56020439/cant-connect-with-upwork-to-get-any-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!