Is there an example of Programmatic Authentication...
# gd-beginners
k
Is there an example of Programmatic Authentication (docs) anywhere? It says "define your own auth flow" but I'm not sure what exactly it wants.
I have seen in the GoodData.UI docs it says the exception should contain a
loginUrl
, but the exceptions I see in my Web Components test don't include such a field. I only see
client
and
backend
objects on the exception.
j
Hi Kayden, As per our previous discussion, Web Components authentication should be done through an SSO. The documentation you are including here is from React UI part of the docs. The programmatic authentication for Web Components is described in the bellow section: https://www.gooddata.com/docs/gooddata-ui/latest/learn/embed_dashboards/web_components/authentication/#WebComponentsauthenti[…]ammaticauthentication
k
Thanks @Julius Kos – I'm specifically lost for the part that says
Copy code
// ... define the logic for custom authentication flow
I linked that document because I was doing my best to follow that document ("See our documentation for more information on GoodData.CN authentication") as best I could. Since (as you say) I'm not meant to use that linked page, where can I find more information about defining custom authentication logic for Web Components? An example would be greatly helpful, if possible.
m
Hello Kayden, the authentication handler function could be defined as follows:
Copy code
function myAuthenticationHandler(authError) {
    if (authError) {
        console.log("There was an issue while authenticating:", authError);
        // Redirect to login page or prompt user to reauthenticate
        window.location.href = "/login";
    } else {
        console.log("Authentication successful!");
    }
}
Since we already provide an authentication mechanism, any changes to it are possible but entirely up to you to implement. Customer use cases can vary widely, so we can’t offer a ‘one size fits all’ example. However, we hope the example above gives you a better idea of how to move forward.
👍 1