Regarding the first scenario:
HTTP 403 - Forbidden error can be thrown when there is any access restriction policy implemented.
- Check the APIM inspector trace and you should notice the existence of a 'ip-filter' policy that filters (allows/denies) calls from specific IP addresses and/or address ranges.
- To check the scope of the 'ip-filter' policy, select the Calculate effective policy button. If you don't see any access restriction policy implemented at any scopes, next validation step should be done at product level, by navigating to the associated product and then click on Policies option.
Regarding the 2nd one i.e., Calling the API from MS Non Prod Tenant gives below error while trying to generate the authorization_code itself.
- To access the API from a different tenant you need to Create a app registration as multi-tenant application in tenant A (eg: TenantAAPI) and expose it as an API (api://app-id/app.read).
- In Tenant B:
- Try to access that TenantAAPI multi-tenant application using a user of Tenant B, so that the application gets added to Tenant B as a service principal.
- Once the application TenantAAPI gets added to Tenant B, you should be able to see its entry under the Enterprise Registration section.
- Create another App Registration in Tenant B (eg: TenantBApp).
- In the API Permissions section of TenantBApp, you can add a permission: Add a Permission --> Select an API --> APIs my Organization Uses --> here search for the api of tenant A i.e TenantAAPI
- Once you find the TenantAAPI, Add its exposed permission i.e app.read as it would be listed there.
Please "Accept the answer (Yes)" and "share your feedback ". This will help us and others in the community as well.
Thanks,
Akshay Kaushik