diff --git a/pkg/interface/src/logic/api/gcp.ts b/pkg/interface/src/logic/api/gcp.ts new file mode 100644 index 0000000000..6f85a322f5 --- /dev/null +++ b/pkg/interface/src/logic/api/gcp.ts @@ -0,0 +1,14 @@ +import BaseApi from './base'; +import {StoreState} from '../store/type'; + + +export default class GcpApi extends BaseApi { + startRefreshLoop() { + this.refreshToken(); + } + + private refreshToken() { + const res = this.spider('noun', 'gcp-token', 'get-gcp-token', {}); + // TODO: store the token, set a timer to refresh it + } +}; diff --git a/pkg/interface/src/logic/api/global.ts b/pkg/interface/src/logic/api/global.ts index 8ed02020b4..edf6f0cc5d 100644 --- a/pkg/interface/src/logic/api/global.ts +++ b/pkg/interface/src/logic/api/global.ts @@ -10,6 +10,7 @@ import GroupsApi from './groups'; import LaunchApi from './launch'; import GraphApi from './graph'; import S3Api from './s3'; +import GcpApi from './gcp'; import {HarkApi} from './hark'; import SettingsApi from './settings'; @@ -20,6 +21,7 @@ export default class GlobalApi extends BaseApi { contacts = new ContactsApi(this.ship, this.channel, this.store); groups = new GroupsApi(this.ship, this.channel, this.store); launch = new LaunchApi(this.ship, this.channel, this.store); + gcp = new GcpApi(this.ship, this.channel, this.store); s3 = new S3Api(this.ship, this.channel, this.store); graph = new GraphApi(this.ship, this.channel, this.store); hark = new HarkApi(this.ship, this.channel, this.store); diff --git a/pkg/interface/src/logic/store/store.ts b/pkg/interface/src/logic/store/store.ts index b2ab60c6c8..cd06ae91cb 100644 --- a/pkg/interface/src/logic/store/store.ts +++ b/pkg/interface/src/logic/store/store.ts @@ -71,6 +71,7 @@ export default class GlobalStore extends BaseStore { }, weather: {}, userLocation: null, + gcp: {}, s3: { configuration: { buckets: new Set(), diff --git a/pkg/interface/src/logic/store/type.ts b/pkg/interface/src/logic/store/type.ts index 96b68f8a2d..6cc9c23a83 100644 --- a/pkg/interface/src/logic/store/type.ts +++ b/pkg/interface/src/logic/store/type.ts @@ -3,6 +3,7 @@ import { Invites } from '~/types/invite-update'; import { Associations } from '~/types/metadata-update'; import { Rolodex } from '~/types/contact-update'; import { Groups } from '~/types/group-update'; +import { GcpState } from '~/types/gcp-state'; import { S3State } from '~/types/s3-update'; import { LaunchState, WeatherState } from '~/types/launch-update'; import { ConnectionStatus } from '~/types/connection'; @@ -32,6 +33,7 @@ export interface StoreState { groupKeys: Set; nackedContacts: Set s3: S3State; + gcp: GcpState; graphs: Graphs; graphKeys: Set; diff --git a/pkg/interface/src/types/gcp-state.ts b/pkg/interface/src/types/gcp-state.ts new file mode 100644 index 0000000000..3f83993060 --- /dev/null +++ b/pkg/interface/src/types/gcp-state.ts @@ -0,0 +1,3 @@ +export interface GcpState { + accessToken: string; +}; diff --git a/pkg/interface/src/views/App.js b/pkg/interface/src/views/App.js index 3e1650dc34..13fd7d9ef1 100644 --- a/pkg/interface/src/views/App.js +++ b/pkg/interface/src/views/App.js @@ -94,6 +94,7 @@ class App extends React.Component { // before the app has actually rendered, hence the timeout. this.updateTheme(this.themeWatcher); }, 500); + this.api.gcp.startRefreshLoop(); this.api.local.getBaseHash(); this.api.settings.getAll(); this.store.rehydrate();