Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Uses correct scopes for google API based on config.js values. (#5066)

Дамян Минков9bb789472e7d
diff --git a/react/features/calendar-sync/actions.web.js b/react/features/calendar-sync/actions.web.js
index 64339f7d89..61107df023 100644
--- a/react/features/calendar-sync/actions.web.js
+++ b/react/features/calendar-sync/actions.web.js
@@ -46,8 +46,7 @@ export function bootstrapCalendarIntegration(): Function {
return Promise.resolve()
.then(() => {
if (googleApiApplicationClientID) {
- return dispatch(
- loadGoogleAPI(googleApiApplicationClientID));
+ return dispatch(loadGoogleAPI());
}
})
.then(() => {
diff --git a/react/features/calendar-sync/web/googleCalendar.js b/react/features/calendar-sync/web/googleCalendar.js
index 11074e2c8b..dfee6ad0e4 100644
--- a/react/features/calendar-sync/web/googleCalendar.js
+++ b/react/features/calendar-sync/web/googleCalendar.js
@@ -43,12 +43,7 @@ export const googleCalendarApi = {
* @returns {function(Dispatch<any>, Function): Promise<void>}
*/
load() {
- return (dispatch: Dispatch<any>, getState: Function) => {
- const { googleApiApplicationClientID }
- = getState()['features/base/config'];
-
- return dispatch(loadGoogleAPI(googleApiApplicationClientID));
- };
+ return (dispatch: Dispatch<any>) => dispatch(loadGoogleAPI());
},
/**
diff --git a/react/features/google-api/actions.js b/react/features/google-api/actions.js
index 4689754115..cc9d371ab9 100644
--- a/react/features/google-api/actions.js
+++ b/react/features/google-api/actions.js
@@ -29,16 +29,22 @@ export function getCalendarEntries(
/**
* Loads Google API.
*
- * @param {string} clientId - The client ID to be used with the API library.
* @returns {Function}
*/
-export function loadGoogleAPI(clientId: string) {
+export function loadGoogleAPI() {
return (dispatch: Dispatch<any>, getState: Function) =>
googleApi.get()
.then(() => {
+ const {
+ liveStreamingEnabled,
+ enableCalendarIntegration,
+ googleApiApplicationClientID
+ } = getState()['features/base/config'];
+
if (getState()['features/google-api'].googleAPIState
=== GOOGLE_API_STATES.NEEDS_LOADING) {
- return googleApi.initializeClient(clientId);
+ return googleApi.initializeClient(
+ googleApiApplicationClientID, liveStreamingEnabled, enableCalendarIntegration);
}
return Promise.resolve();
diff --git a/react/features/google-api/googleApi.web.js b/react/features/google-api/googleApi.web.js
index a05b90fba6..f3f1470751 100644
--- a/react/features/google-api/googleApi.web.js
+++ b/react/features/google-api/googleApi.web.js
@@ -61,11 +61,17 @@ const googleApi = {
* making Google API requests.
*
* @param {string} clientId - The client ID to be used with the API library.
+ * @param {boolean} enableYoutube - Whether youtube scope is enabled.
+ * @param {boolean} enableCalendar - Whether calendar scope is enabled.
* @returns {Promise}
*/
- initializeClient(clientId) {
+ initializeClient(clientId, enableYoutube, enableCalendar) {
return this.get()
.then(api => new Promise((resolve, reject) => {
+ const scope
+ = `${enableYoutube ? GOOGLE_SCOPE_YOUTUBE : ''} ${enableCalendar ? GOOGLE_SCOPE_CALENDAR : ''}`
+ .trim();
+
// setTimeout is used as a workaround for api.client.init not
// resolving consistently when the Google API Client Library is
// loaded asynchronously. See:
@@ -74,10 +80,7 @@ const googleApi = {
api.client.init({
clientId,
discoveryDocs: DISCOVERY_DOCS,
- scope: [
- GOOGLE_SCOPE_CALENDAR,
- GOOGLE_SCOPE_YOUTUBE
- ].join(' ')
+ scope
})
.then(resolve)
.catch(reject);
diff --git a/react/features/recording/components/LiveStream/web/StartLiveStreamDialog.js b/react/features/recording/components/LiveStream/web/StartLiveStreamDialog.js
index 51dee07bf3..d3ce0e0eb7 100644
--- a/react/features/recording/components/LiveStream/web/StartLiveStreamDialog.js
+++ b/react/features/recording/components/LiveStream/web/StartLiveStreamDialog.js
@@ -121,8 +121,7 @@ class StartLiveStreamDialog
* @returns {void}
*/
_onInitializeGoogleApi() {
- this.props.dispatch(
- loadGoogleAPI(this.props._googleApiApplicationClientID))
+ this.props.dispatch(loadGoogleAPI())
.catch(response => this._parseErrorFromResponse(response));
}