Michael Serres
10/26/2022, 12:52 PMMatyáš Kandl
10/26/2022, 2:14 PMconst decoratedBackend = withNormalization(
withCaching(
bearFactory(backendConfig),
RecommendedCachingConfiguration),
)
);
const backendWithAuth = decoratedBackend.withAuthentication(...)
Michael Serres
10/26/2022, 2:48 PMMichael Serres
10/26/2022, 2:50 PMMichael Serres
10/26/2022, 3:56 PMDan Homola
10/27/2022, 7:24 AMsdk
property directly? Can you use
import sdk from "@gooddata/api-client-bear";
const backend = useBackend();
const relayState = "<https://rentaleye.central.sc/>";
// ...
const isLoggedIn = backend.isAuthenticated().then((isLogged) => {
if (!isLogged) {
process.env.REACT_APP_SET_HOSTNAME &&
sdk.user.initiateSamlSso(relayState);
}
});
That way you will use the backend
object as intended: in a backend-implementation-agnostic fashion and you would only use the backend-specific functionality to do the backend-specific SSO call.
Accessing the sdk
property of the backend
object is discouraged as it is a private property and can be removed in future releases (it also is not “forwarded” by the decorators as you encountered).
Cc @Matyáš KandlDan Homola
10/27/2022, 7:41 AMIAuthenticationProvider
and use it instead of the ContextDeferredAuthProvider
you currently use. There, you could implement the authenticate
method yourself, triggering the SSO flow from there (the IAuthenticationProvider
has better access to the sdk
object you can use to make the SSO call). See the existing ContextDeferredAuthProvider implementation for some inspiration, there you would replace the NotAuthenticated error by the SSO call using the sdk
object.Michael Serres
10/27/2022, 1:47 PMMichael Serres
11/22/2022, 6:05 AMDan Homola
11/22/2022, 7:58 AMbackend
instance misconfigured. You used the @gooddata/create-gooddata-react-app
to create your app, right? If so, please make sure you are using the build-with-explicit-hostname
npm script to build your app (not the plain build
). This should make sure your app will work properly even when deployed. More details should be available at the end of the README.md file of your created app.Michael Serres
11/23/2022, 12:53 PMMichael Serres
11/23/2022, 12:54 PMDan Homola
11/23/2022, 1:15 PMbackend
value in your src/constants
file?Michael Serres
11/23/2022, 2:24 PMDan Homola
11/23/2022, 2:34 PMMichael Serres
11/23/2022, 3:39 PMMichael Serres
11/23/2022, 3:39 PMDan Homola
11/23/2022, 3:46 PMMichael Serres
11/23/2022, 3:51 PMMichael Serres
11/23/2022, 3:53 PMDan Homola
11/23/2022, 3:55 PMDan Homola
11/23/2022, 3:57 PMMichael Serres
11/23/2022, 3:59 PMDan Homola
11/23/2022, 4:13 PMconst getExportUri = async () => {
try {
return (await exportFunction(exportConfig!))?.uri;
} catch (error) {
let errorMessage = error.message;
if (error.responseBody) {
errorMessage = JSON.parse(error.responseBody)?.error?.message;
}
throw errorMessage;
}
};
please try
const getExportUri = async () => {
try {
const relativeUri = (await exportFunction(exportConfig!)).uri;
// when running on custom hostname, explicitly prepend it
// otherwise the export result would be loaded from wrong origin
return backend.config.hostname
? new URL(relativeUri, backend.config.hostname).href
: relativeUri;
} catch (error) {
let errorMessage = error.message;
if (error.responseBody) {
errorMessage = JSON.parse(error.responseBody)?.error?.message;
}
throw errorMessage;
}
};
where backend
can be obtained using the useBackendStrict
hook from @gooddata/sdk-model
Dan Homola
11/23/2022, 4:13 PM