I have a requirement wherein I want to give consent to a multi-tenant application (belonging to a different tenant) for our tenant programmatically. Currently I am able to provide consent interactively by opening the following consent URL in my browser and using my user's credentials to login and accept multi-tenant app's permissions: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize.
Can the same be achieved programmatically? Though I am currently using authorization code flow, but I am open to use any other OAuth 2.0 flow which assists in making consent process programmatic. I tried searching online for either azure CLI or Java SDK APIs but had no luck. I am guessing it is mostly not possible but wanted to make sure of the same.
Thanks!