Open-EO / openeo-js-client

JavaScript and TypeScript client for the openEO API.
https://open-eo.github.io/openeo-js-client/latest/
Apache License 2.0
15 stars 6 forks source link

TypeError: con.authenticateOIDC is not a function #58

Closed rifatSDAS closed 9 months ago

rifatSDAS commented 9 months ago

Hi,

I am trying to test openEO JS client for my web app. During testing I got these errors

I am trying the Full Example from https://documentation.dataspace.copernicus.eu/APIs/openEO/JavaScript_Client/JavaScript.html

When

var con = await OpenEO.connect("https://openeo.dataspace.copernicus.eu");
// Authenticate ourselves via Basic authentication
await con.authenticateOIDC();

ERROR TypeError: con.authenticateOIDC is not a function

And when I am using await con.authenticateBasic("my-CDSE-username", "my-CDSE-password");

ERROR Error: Credentials are not correct

N.B. I calling openEO api from HTML script tags

<script src="https://cdn.jsdelivr.net/npm/axios@0.21/dist/axios.js"></script>
<script src="https://cdn.jsdelivr.net/npm/oidc-client@1/lib/oidc-client.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@openeo/js-client@2/openeo.js"></script>

Any insight will be appreciated :-)

m-mohr commented 9 months ago

authenticateOIDC doesn't exist, the docs in the CDSE are wrong. Please contact them to get it fixed. You need to use listAuthProviders and then filter for the OIDC Proivder(s) you want to use. https://open-eo.github.io/openeo-js-client/latest/Connection.html#listAuthProviders

Something like should give you all OIDC providers configured through the API:

let providers = await con.listAuthProviders();
let oidcProviders = providers.filter(p => p.getType() === "oidc");