【问题标题】:Developer Inactive error when calling UnderArmour api调用 UnderArmour api 时出现开发人员不活动错误
【发布时间】:2016-11-04 05:51:30
【问题描述】:

尝试在 UnderArmour Connected Fitness api 中发布到 access_token endpoint 时收到 403“Developer Inactive”错误。正在使用的 client_id 处于活动状态。调用中使用的url为:https://api.ua.com/v7.1/oauth2/access_token/

这是获取授权码后使用python调用的sn-p:

import requests 
access_token_url = 'https://api.ua.com/v7.1/oauth2/access_token/'

access_token_data = {'grant_type': 'authorization_code', 
                     'client_id': CLIENT_ID,
                     'client_secret': CLIENT_SECRET,
                     'code': authorize_code}

response = requests.post(url=access_token_url, data=access_token_data)

In [24]: response
Out[24]: <Response [403]>

In [25]: response.content
Out[25]: '<h1>Developer Inactive</h1>'

其中 CLIENT_ID 和 CLIENT_SECRET 是我在开发者门户上的注册值。

【问题讨论】:

    标签: python api oauth2 mapmyfitness underarmour


    【解决方案1】:

    对 api.ua.com 的所有调用都必须包含一个 'api-key' 标头值,否则,您将收到 403 Developer Inactive 错误。

    这个 sn-p 显示了如何在 python 中做到这一点:

    import requests 
    access_token_url = 'https://api.ua.com/v7.1/oauth2/access_token/'
    
    access_token_data = {'grant_type': 'authorization_code', 
                         'client_id': CLIENT_ID,
                         'client_secret': CLIENT_SECRET,
                         'code': authorize_code}
    
    headers = {'api-key': CLIENT_ID}
    
    response = requests.post(url=access_token_url, data=access_token_data, headers=headers)
    
    In [30]: response
    Out[30]: <Response [200]>
    
    In [31]: response.content
    Out[31]: '{"user_id": "<user_id>", "access_token": "<access token>", "expires_in": 2591999, "token_type": "Bearer", "scope": "read", "user_href": "/v7.1/user/<user id>/", "refresh_token": "<refresh token>"}'
    

    【讨论】:

    • x-api-key 和 api-key 有什么区别吗?
    猜你喜欢
    • 1970-01-01
    • 2019-06-15
    • 2015-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-22
    • 2019-03-21
    相关资源
    最近更新 更多