Daniel
03/17/2022, 10:52 PMimport sdk from "@gooddata/api-client-bear";
const relayState = "<https://my.app.com/>";
sdk.user
.initiateSamlSso(relayState)
.catch(error => {
// something went wrong, see the browser console for details
console.error(error);
});
The error:
Error: Cannot parse responseBody.
at e.getDataInner (xhr.ts:135:19)
at e.getData (xhr.ts:124:21)
at user.ts:309:29
Does anyone know why I could be getting this?Jiri Zajic
03/18/2022, 1:49 AM<https://my.app.com/>
example domain that does not return parsable responseBody? Where does your analytical application run?Jiri Zajic
03/18/2022, 1:52 AMimport { factory } from "@gooddata/api-client-bear";
const domain = "<https://my.app.com/>";
const sdk = factory({ domain });
Jiri Zajic
03/18/2022, 1:54 AMDan Homola
03/18/2022, 8:36 AMDaniel
03/18/2022, 4:59 PMbackend
, rather than importing sdk
. See below:
import { useBackend } from "@gooddata/sdk-ui";
const backend = useBackend();
backend?.sdk.user
.initiateSamlSso(URL)
.catch((error: any) => {
console.error(error);
});
Jiri Zajic
03/18/2022, 8:15 PMsdk
is correct?Dan Homola
03/21/2022, 8:38 AMbackend?.sdk.user
… call is potentially brittle, the sdk
prop is marked as private so it might dissappear at any time. It is surprising to me that the default import did not work for you, but what @Jiri Zajic is suggesting might be the correct way after all as it is basically what the sdk-backend-bear does. So please in this case please prefer some form of import directly from the api-client-bear package. Hope this clears things up 🙂Daniel
03/21/2022, 7:13 PMsdk
like this to be able to successfully call sdk.user.initiateSamlSso
in a way that will be reliable?
import { factory } from "@gooddata/api-client-bear";
const domain = "<https://my.app.com/>";
const sdk = factory({ domain });
Dan Homola
03/22/2022, 8:20 AMDaniel
03/22/2022, 7:02 PMDaniel
03/22/2022, 8:43 PMError: Cannot parse responseBody.
errorDan Homola
03/23/2022, 8:18 AM/
from the domain. Can you please try specifying the domain without th trailing slash?Daniel
03/23/2022, 9:05 PM/
from the domain also didn't work. I had a support case open about this if you'd like to see more details about our setup. They recommended we make all of our API requests through the useBackend()
hook. We were doing our authentication with the Auth0 library originally, which the GoodDataUI SDK didn't seem to supportDan Homola
03/24/2022, 8:27 AMimport { factory } from "@gooddata/api-client-bear";
const domain = "<https://my.app.com>";
const sdk = factory();
sdk.config.setCustomDomain(domain);
sdk.user.initiateSamlSso(URL).catch((error: any) => {
console.error(error);
});
because this is what the bearFactory
does internally. Can you please try that?