What I’m trying to achieve:
- On a deployed instance on Daml hub, include “Reader” in the “readAs: ” key in the JWT.
Steps taken:
- Trying to setup custom Auth0, using Auth0 react component, and following the steps here:
Easy authentication for your distributed app with Daml and Auth0
However, the steps above don’t seem to work for a deployed version, and only locally as well. - I’ve followed all the steps above, and was also able to figure out how to include part and token params in the redirect Url.
I didn’t change the LoginScreen.tsx code, from the create-daml-app template, and I’m able to get back my custom JWT,
Using the Auth0 hook loginWithRedirect
, I’m able to authenticate, and create a callbackUrl which gets passed to the below, (I believe this is similar to how when deploying on dabl is)
however the code errors out at the line where
const ledger = new Ledger({ token: credentials.token, httpBaseUrl });
I get the error CORS: invalid origin ‘https://vqe14zmbblsl30te.projectdabl.com’
The request url is Request URL: https://api.projectdabl.com/data/vqe14zmbblsl30te/v1/fetch
The code in LoginScreen.tsx
const login = useCallback(async (credentials: Credentials) => {
try {
const ledger = new Ledger({ token: credentials.token, httpBaseUrl });
let userContract = await ledger.fetchByKey(User.User, credentials.party);
if (userContract === null) {
const user = { username: credentials.party, following: [], followers: [], influence: '0.0', reader: "Write" };
userContract = await ledger.create(User.User, user);
}
onLogin(credentials);
} catch (error) {
alert(`Unknown error:\n${error}`);
}
}, [onLogin]);
Is it actually possible to create my own Auth0 settings, use a custom JWT and query a ledger deployed on daml hub?
In fact I was looking at this post as well
but again, not sure if this was done locally or not.