SET_CONFIG: ofType<{ config: Config }>(),
SET_EXTRA_TOKEN: ofType<{ extraApiToken: string, extraApiTokenExpiration?: Date }>(),
RESET_EXTRA_TOKEN: {},
SET_CONFIG: ofType<{ config: Config }>(),
SET_EXTRA_TOKEN: ofType<{ extraApiToken: string, extraApiTokenExpiration?: Date }>(),
RESET_EXTRA_TOKEN: {},
export const saveApiToken = (token: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
let config: any;
const tokenParts = token.split('/');
export const saveApiToken = (token: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
let config: any;
const tokenParts = token.split('/');
// If the token is from a LoginCluster federation, get user & token data
// from the token issuing cluster.
// If the token is from a LoginCluster federation, get user & token data
// from the token issuing cluster.
const lc = (config as Config).loginCluster
const tokenCluster = tokenParts.length === 3
? tokenParts[1].substring(0, 5)
const lc = (config as Config).loginCluster
const tokenCluster = tokenParts.length === 3
? tokenParts[1].substring(0, 5)
const tokenLocation = await svc.authService.getStorageType();
dispatch(authActions.INIT_USER({ user, token, tokenExpiration, tokenLocation }));
} catch (e) {
const tokenLocation = await svc.authService.getStorageType();
dispatch(authActions.INIT_USER({ user, token, tokenExpiration, tokenLocation }));
} catch (e) {
const client = await svc.apiClientAuthorizationService.get('current');
dispatch(authActions.SET_EXTRA_TOKEN({
extraApiToken: extraToken,
const client = await svc.apiClientAuthorizationService.get('current');
dispatch(authActions.SET_EXTRA_TOKEN({
extraApiToken: extraToken,
const newExtraToken = getTokenV2(client);
dispatch(authActions.SET_EXTRA_TOKEN({
extraApiToken: newExtraToken,
const newExtraToken = getTokenV2(client);
dispatch(authActions.SET_EXTRA_TOKEN({
extraApiToken: newExtraToken,