As mentioned in your question, https://apim.docs.wso2.com/en/next/learn/api-security/oauth2/grant-types/password-grant/
This method will only work when you have the resource owner's username and password.
Take an example, suppose you have published the APIs and created a user (resource owner) in the WSO2 store. this user is subscribed to the API using the application. the application will have a client id and secret, which will be used to generate the OAuth2.0 token. this token will be used to invoke the APIs.
Now in your angular project, one way is to hardcode the base64(clientid:clientsecret) and call the token API to generate the OAuth2.0 bearer token. use the generated token to call the APIs onboarded on WSO2. To protect your APIs from the attack, use rate limiting based on IP
Now take another situation, if you want the user to authenticate first, then generate the JWT token
for that user using the password grant type (using actual user's username and password), and using that JWT generate the OAuth2.0 Bearer token
which will be used to call the APIs.
Steps to be performed for the second situation:
- during registration (from Angular), internally onboard the user in the WSO2 Identity Server. (There is a WSO2 API for the same)
- After registration, generate the JWT token from the identity server by authenticating username and password. (Again for this, WSO2 API is there)
- now using this JWT token, Generate the OAuth2.0 token from WSO2 APIM
- use this token to call the APIs
The second approach is the ideal approach for user to service authentication and authorization using WSO2 as the gateway while the first approach mainly focuses on service to service authentication and authorization
Hope this answers your question
Reference Link: https://medium.com/wso2-learning/how-to-protect-your-apis-with-self-contained-access-token-jwt-using-wso2-api-manager-and-wso2-75673d8a4686