KirubaPradeep
KirubaPradeep

Reputation: 327

HUAWEI Push - API for obtaining an access token not working

When I use this api to get access token: https://oauth-login.cloud.huawei.com/oauth2/v3/token?grant_type=client_credentials&client_id=****&client_secret=**** it always returns

{
"sub_error": 20001,
"error_description": "missing required parameter: client_id",
"error": 1102 }

although I send client_id parameter

Upvotes: 1

Views: 979

Answers (2)

Zinna
Zinna

Reputation: 2025

Please use the following scheme instead for oath authentication:

https://oauth-login.cloud.huawei.com/oauth2/v3/authorize?grant_type=client_credentials&client_id=\*\*\*\*&client_secret=\*\*\*

If you don't give this a valid client_id it will say that you have a "invalid client_id" instead of saying it's empty. Hope this helps. (The change is that the original says .../token? and this says .../authorize?)

Upvotes: 0

KirubaPradeep
KirubaPradeep

Reputation: 327

To solve the issue, Please make sure the below points

  1. You are doing post request to the server

  2. Make sure that the POST URL is “https://oauth-login.cloud.huawei.com/oauth2/v3/token”. Do not include post parameters in the URL

  3. Add below parameters in body of POST request but not in the URL as mentioned here ( https://oauth-login.cloud.huawei.com/oauth2/v3/token?grant_type=client_credentials&client_id=****&client_secret=**** )

grant_type=client_credentials

client_id=****

client_secret=****

For more details about fetching the access token, please refer the below link:

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides-V5/open-platform-oauth-0000001053629189-V5#EN-US_TOPIC_0000001053629189__section12493191334711

Upvotes: 1

Related Questions