2017-06-20 7 views
1

this guideを使用してアクセストークンを取得しようとしています。何 - 私はイライラしてるアクセストークン(認証トークンの交換)をPythonリクエストで受け取ります

{u'error_description': u'request is missing a required parameter or malformed.', u'error': u'invalid_request'} 

import requests 

from utils import make_basic_auth_header, conf 
code = '<Auth code here>' 
url = "%s/identity/v1/oauth2/token" % conf('EBAY_API_PREFIX') 
headers = { 
     'Content-Type': 'application/x-www-form-urlencoded', 
     'Authorization': make_basic_auth_header() 
    } 

data = { 
    'grant_type': 'authorization_code', 
    # 'grant_type': 'refresh_token', 
    'state': None, 
    'code': code, 
    'redirect_uri': conf('EBAY_RUNAME') 
} 
r = requests.post(
    url, 
    data=data, 
    headers=headers, 
) 

ここmake_basic_auth_header()機能です:

def make_basic_auth_header(): 
    auth_header_payload = '%s:%s' % (conf('EBAY_APP_ID'), conf('EBAY_CERT_ID')) 
    auth_header_base64 = base64.b64encode(auth_header_payload) 
    auth_header = 'Basic %s' % auth_header_base64 
    return auth_header 

しかし、私はr.json()に入るすべてがある。ここ

は私のメインのファイルがあります私は間違っている?

+0

追加:私のファイルには、unicodeではなくpython2文字列があります。私もユニコードに切り替えることを試みた - それは助けていない –

+0

あなたはjsonフォーマットのstrとしてデータdictを渡そうとしましたか?例えば。 'import json'の後' data = json.dumps(data) ' – etemple1

答えて

1

申し訳ありませんが、私は十分に愚かで、私はeBayでティックボックスを見ませんでした。 here's the tickbox, after I've clicked it

関連する問題