appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

[Bug]: Re-authorization issue in datasource

Open SreelakshmiV12 opened this issue 3 years ago • 5 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

I have created a datasource with Authentication Type: Oauth 2.0 and Grant type : Authorization code, and saved the datasource in my app. When I tried to run a graph API ( https://graph.microsoft.com/v1.0/teams/{{teamsid}}/channels/{{channelid}}/messages ) using this datasource, it failed because access token was expired within 1 hour. So I need to re-authorize datasource in every hour to run the API. I need to know that how to re-authorize without coming to datasource.

Steps To Reproduce

  1. Create new datasource (Autheniticated API) with Authentication Type: Oauth 2.0 and Grant type : Authorization code
  2. Create an API using this datasource.
  3. API run without any error initially. But after every hour, access token was expired and we need to re-authorize datasource to fix the error.

Public Sample App

No response

Version

Appsmith v1.7.8

SreelakshmiV12 avatar Jul 22 '22 04:07 SreelakshmiV12

@SreelakshmiV12 could you please point us in the direction of the documentation for this API?

Nikhil-Nandagopal avatar Aug 01 '22 13:08 Nikhil-Nandagopal

https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http - This is the API documentation. This API is used to send messages to teams through appsmith.

SreelakshmiV12 avatar Aug 02 '22 04:08 SreelakshmiV12

Hey @SreelakshmiV12 ! Do you think you can share a screenshot of the way your datasource is configured? Please make sure to hide any sensitive data in the screenshot before you post it here. :)

nidhi-nair avatar Aug 16 '22 07:08 nidhi-nair

@nidhi-nair I can share screenshots. Everythig works well. I can configure google analytics, fetch data, process them, combine with other data, no need extra scripts and re-input data for OAuth2 authification, system can do it by itself ............ everything is fine. But one big trouble exists that has bad effect on production using - system can not re-autorize expired oauth token for datasource automaticly, need press button save and autorize. We use the latest version of appsmith, updating once per week, now its version 1.8.15.

ps. Maybe I configured something wrong? Or some hack exists for emulate this re-authorize, forcing it? (I tried call screen2 button url in rest api - but unauthorized in appsmith, not easy way)?

screen 1: Screenshot from 2023-01-03 21-31-48

screen 2: Screenshot from 2023-01-03 21-33-43

screen 3: this-one

SKovbel avatar Jan 03 '23 21:01 SKovbel

Hey @SKovbel ! There's a guide in our documentation for Google Sheets that might help you out here. Google uses the following two custom parameters to make sure that tokens are refreshed automatically without needing a user to authorize it.

prompt: consent
access_type: offline

cc: @rohan-arthur @pranavkanade

nidhi-nair avatar Jan 04 '23 07:01 nidhi-nair

@nidhi-nair Yes, it works, whole day without re-auithorize. Thanks a lot.

SKovbel avatar Jan 05 '23 00:01 SKovbel