Content Security Policy directive: “frame-ancestors ‘none’ When Using getAccessTokenSilently with Auth0

When we attempt to get a token using getAccessTokenSilently after a session has expired, we receive the following error:

Refused to frame 'https://****.uk.auth0.com/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'none'

//_app.tsx

import React from 'react';
import { Provider } from 'react-redux';
import { Auth0Provider, useAuth } from '@auth0/auth0-react';
import axios from 'axios';
import { ApiProvider } from './ApiProvider';
import { store } from './store';
import appConfig from './config';
import { handleOnRedirectCallback } from './auth';

const ApiProviderCustom = (props: ExtendedAppProps) => {
  const { Component, pageProps } = props;
  const { user, isAuthenticated, getAccessTokenSilently } = useAuth();

  const instance = axios.create();

  if (user && isAuthenticated) {
    instance.interceptors.request.use(
      async config => {
        const accessToken = await getAccessTokenSilently();
        config.headers.Authorization = `Bearer ${accessToken}`;
        return config;
      },
      error => Promise.reject(error)
    );
  }

  return (
    <ApiProvider instance={instance}>
      <Component {...pageProps} />
    </ApiProvider>
  );
};

const App = (props: ExtendedAppProps) => {
  return (
    <Provider store={store}>
      <Auth0Provider
        domain={appConfig.auth.CLIENT_DOMAIN}
        clientId={appConfig.auth.CLIENT_ID}
        authorizationParams={{
          audience: appConfig.auth.AUDIENCE,
          scope: appConfig.auth.SCOPE.replace(',', ' '),
          redirect_uri: typeof window !== 'undefined' ? window.location.origin : undefined,
        }}
        cacheLocation='localstorage'
        onRedirectCallback={handleOnRedirectCallback}
      >
        <ApiProviderCustom {...props} />
      </Auth0Provider>
    </Provider>
  );
};

export default App;
//ApiContect.tsx

import { ReactNode, createContext } from 'react'
import { ApiContextType } from 'src/types/global'
import BackendApi from 'src/api/BackendApi'
import { useAuth } from 'src/hooks/useAuth'
import { isDefined } from 'src/utils/miscellaneous'
import { AxiosInstance } from 'axios'
import appConfig from 'src/configs/appConfig'

type Props = {
  instance: AxiosInstance
  children: ReactNode
}

const defaultProvider: ApiContextType = {
  backendApi: new BackendApi(undefined, appConfig.backend_base_url, undefined, appConfig.machine_learning_base_url)
}

const ApiContext = createContext(defaultProvider)

const ApiProvider = ({ instance, children }: Props) => {
  // ** Hooks
  const { user, isAuthenticated } = useAuth()

  if (isDefined(user) && isAuthenticated) {
    const authenticatedProvider: ApiContextType = {
      backendApi: new BackendApi(undefined, appConfig.backend_base_url, instance, appConfig.machine_learning_base_url)
    }

    return <ApiContext.Provider value={authenticatedProvider}>{children}</ApiContext.Provider>
  } else {
    return <ApiContext.Provider value={defaultProvider}>{children}</ApiContext.Provider>
  }
}

export { ApiContext, ApiProvider }

Allow the user session to expire.
Call getAccessTokenSilently to retrieve a new access token.
Observe the error in the console.

We are using Universal Login for our Auth0 setup.
This issue appears to be related to the Content Security Policy settings of our Auth0 tenant. The frame-ancestors ‘none’ directive is preventing the request.

New contributor

Parth Parmar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật