首页 文章

调用UnderArmour api时,Developer Inactive错误

提问于
浏览
4

尝试发布UnderArmour Connected Fitness api中的access_token endpoint时收到403 "Developer Inactive"错误 . 正在使用的 client_id 处于活动状态 . 通话中使用的网址是:https://api.ua.com/v7.1/oauth2/access_token/

在获得授权代码后,这是使用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}

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是我在开发人员门户网站上的注册值 .

1 回答

  • 3

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

    这段代码展示了如何在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>"}'
    

相关问题