0

I was trying to test publisher apis documented here "RESTful API for WSO2 API Manager - Publisher"

To execute any api i need a admin access toke. To generate that, it is advised to run following command :

curl -k -d "grant_type=password&username=admin&password=admin&scope=apim:api_view" -H "Authorization: Basic SGZFbDFqSlBkZzV0YnRyeGhBd3liTjA1UUdvYTpsNmMwYW9MY1dSM2Z3ZXpIaGM3WG9HT2h0NUFh" https://127.0.0.1:8243/token

I replaced basic authorization with admin and password of admin user. I got following error when i attempted to execute it:

{
  "error": "invalid_client",
  "error_description": "Oauth application is not in active state."
}    
Status Code : 401 Unauthorized

please advise what is wrong here. Thanks.

2 Answers 2

5

Authorization header should contain the base64 encoded value of clientId:secret

You should first obtain clientId and secret with curl command 1 and then execute [2]

1 curl -X POST -H "Authorization: Basic base64(username:password)" -H "Content-Type: application/json" -d <payload> http://localhost:9763/client-registration/v0.11/register

A sample json is found in this document.

[2] curl -k -d "grant_type=password&username=<username>&password=<password>&scope=apim:api_view" -H "Authorization: Basic base64(clientId:secret)" https://127.0.0.1:8243/token

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! i was thinking step1 and 2 are separate activities. Thanks for help. Its working now for me.
0

Similar to the accepted answer, it led me to check the encoding of the client id and secret that I had copied from another app.

Solution:

Though I couldn't visually see the difference, I copied the client id and secret directly from ws02 and pasted into postman auth and that fixed it.

Even though the characters were the same the above solution worked. It leads me to believe one or more of the characters were encoded in the wrong character encoding or I had an invisible character in there. Another developer also had this same issue with copy/paste.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.