betodealmeida commented on code in PR #27631: URL: https://github.com/apache/superset/pull/27631#discussion_r1540042915
########## superset/db_engine_specs/gsheets.py: ########## @@ -136,6 +153,89 @@ def extra_table_metadata( return {"metadata": metadata["extra"]} + @staticmethod + def is_oauth2_enabled() -> bool: + """ + Return if OAuth2 is enabled for GSheets. + """ + return "Google Sheets" in current_app.config["DATABASE_OAUTH2_CREDENTIALS"] + + @staticmethod + def get_oauth2_authorization_uri(state: OAuth2State) -> str: + """ + Return URI for initial OAuth2 request. + + https://developers.google.com/identity/protocols/oauth2/web-server#creatingclient + """ + config = current_app.config["DATABASE_OAUTH2_CREDENTIALS"]["Google Sheets"] + redirect_uri = current_app.config.get( + "DATABASE_OAUTH2_REDIRECT_URI", + state["default_redirect_uri"], + ) + + encoded_state = jwt.encode( + payload=state, + key=current_app.config["SECRET_KEY"], + algorithm=current_app.config["DATABASE_OAUTH2_JWT_ALGORITHM"], Review Comment: Yeah, good idea! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org