appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.68k stars 3.75k forks source link

[Bug]: It is not possible to send <<APPSMITH_USER_OAUTH2_ACCESS_TOKEN>> as a bearer token in the authenticate API. #25496

Open felix-appsmith opened 1 year ago

felix-appsmith commented 1 year ago

Is there an existing issue for this?

Description

Currently, when I send the token I obtained after logging in with OAuth to Appsmith and try to use it as a bearer token in an authenticated data source, and then use that token in my API, it fails. This is because Appsmith sends <> to the API instead of sending the actual token.

image image image

Steps To Reproduce

  1. Create an API that requires a token. You can use it to connect to Google Sheets from Python.
    
    from flask import Flask, request,jsonify
    import requests

app = Flask(name)

@app.route('/GetFiles', methods=['POST']) def get_files(): url = "https://sheets.googleapis.com/v4/spreadsheets/<>" bearer_token = request.headers.get('Authorization') print(bearer_token) headers = { "Authorization": f"Bearer {bearer_token}" } response = requests.get(url, headers=headers)

if response.status_code == 200:
    data = response.json()
    return jsonify(data), 200
else:
    return jsonify({"error": "Error en la solicitud a Google Sheets API"}), response.status_code

if name == 'main': app.run()


2. Configure the Authenticate API now as shown in the image.
![image](https://github.com/appsmithorg/appsmith/assets/114161539/eb46ef99-4b88-4570-b5f5-6ae47d1efdf1)

3. Execute the API, and you will see the error.

### Public Sample App

_No response_

### Environment

Production

### Issue video log

_No response_

### Version

Self-Hosted 1.9.27
felix-appsmith commented 1 year ago

The workaround is to send the authorization token directly from the header and not as a token from the Authorization. Configure it as shown in the following image. image

alexanoid commented 1 month ago

I have the same issue in Appsmith Free CE. I tried passing <> for GraphQL data source as suggested, but none of the solutions worked.

Should this work in the Appsmith Free CE version?

rohan-arthur commented 1 month ago

@alexanoid did you try out the workaround suggested by felix in the comment above? i.e. , send the token as a header param