1

我尝试在烧瓶中使用 upwork api 来获取一些信息,但它不起作用。我怎么能通过它的 api 从 upwork 中得到一些东西?

文件 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')

文件视图.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

当我调用“print(request_token)”时,它会打印“null:null”

4

1 回答 1

0

请,

  1. 检查 view.py 中的代码:您使用不存在的访问令牌/秘密重新定义客户端(根据您的描述判断)。结果,对于不存在的令牌-秘密对,您会得到 404。

  2. 检查http://upwork.github.io/python-upwork/getting_started.html#simple-example上的文档

  3. 尝试使用唯一的 python-upwork 库来实现一个简单的请求,然后才将代码移动到烧瓶下,以避免代码中出现任何意外行为。

于 2019-05-08T11:02:50.010 回答