'Authorize Microsoft Graph User with OAuth 2.0 type to Appsmith

Intro

I want to use Appsmith for internal applications.

In my Appsmith applications, I need to login Office365 Users.

In my understanding, to do that I have to "Get access on behalf of user", as described here.

In this tutorial, the friend is describing how to do Postman requests for MS Graph API calls, where I was able to successfully do that.

Appsmith also provides a "Create new API" option, where you can also have a OAuth 2.0 Authentication datasource, where I can run my HTTP requests and get the responses.

The Question

In this tutorial from the minute I share it, the user needs to press the button in order to get a new access token. I was wondering If this is able to be done in Appsmith ONLY from the application's User Interface, or in Postman without having to press the button "get new access token".

EDIT

In more detail, I would like to implement in Appsmith the following flow only via the UI.

  1. Make GET Request to https://login.microsoftonline.com/{{tenant_id}}/oauth2/v2.0/authorize?client_id={{client_id}}6&response_type=code&redirect_uri=https://app.appsmith.com/api/v1/datasources/authorize&response_mode=query&scope=offline_access%20user.read%20mail.read&state=12345

  2. Login with my account through the dialog box

  3. Redirect to https://app.appsmith.com/api/v1/datasources/authorize?code=[code]

  4. Make POST Request to the https://login.microsoftonline.com/{{tenant_id}}/oauth2/v2.0/token

with body:

{
    code: [code] (how do I get it),
    client_secret: {{client_secret}},
    client_id: {{client_id}},
    scope: https://graph.microsoft.com/User.Read,
    redirect_uri: https://app.appsmith.com/api/v1/datasources/authorize
}

So, the Main Question is: How do I get the [code] from step 3, so I can use it in the body of step 4

Edit 2

Appsmith also provides curl option. Could I solve this via curl?



Solution 1:[1]

this is not possible to access from the application interface yet since the OAUth is configured for a single datasource and not separately for every user today. You can authorise the OAuth app with a common set of credentials so your users need not authenticate it themselves

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nikhil Nandagopal