Hello @Akash Sharma,
Thank you for posting your query on Microsoft Q&A.
Based on your description, I understand that you are generating a bearer token using the OAuth 2.0 client credential flow with parameters such as client_id, client_secret, and tenant_id for the scope "https://management.azure.com"
. Using the token, you were able to retrieve details for a single resource group, and now you want to do the same for all resource groups in your subscription. Please let me know if my understanding is incorrect.
The process you followed to generate the bearer token and retrieve subscription-level data is correct. With the token, you can access and manage all resource groups created under that subscription. Below are additional details and examples to guide you further:
Here is an example of the bearer token retrieval:
Using the above access token, you can retrieve details of all resource groups by making a request similar to the following:
POST https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/query?api-version=2022-10-01
If you encounter any error message while attempting to make a call to another resource group, please attach a screenshot for better understanding and troubleshooting of the issue.
I hope this information is helpful. Please feel free to reach out if you have any further questions.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Thanks,
Raja Pothuraju.