Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OidcTrustedDomains trustedDomains.config_show_access_token not working. Can't get access token in code. #1486

Open
JevgeniF opened this issue Dec 5, 2024 · 1 comment

Comments

@JevgeniF
Copy link

JevgeniF commented Dec 5, 2024

Issue and Steps to Reproduce

Configure OidcProvider to use OidcServiceWorker
Add domains to trustedDomains, add same domains to config_show_access_token and allow to show access token.

Provider config:

const oidcConf = {
        client_id: idpConf.clientId,
        authority: idpConf.issuer,
        scope: idpConf.scope,
        redirect_uri: `${ rootUrl }/authentication/callback`,
        silent_redirect_uri: `${ rootUrl }/authentication/silent_callback`,
        service_worker_relative_url: '/OidcServiceWorker.js',
        service_worker_only: false,
        configuration: {
            token_automatic_renew_mode: TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted
        }

OidcTrustedDomains file content (actual user domain used instead of [user_domain]):
const trustedDomains = {
default: [
'https://[user_domain].zitadel.cloud',
'https://[user_domain].zitadel.cloud/oauth/v2/token',
'http://localhost:3000',
'http://localhost:3000/workloads',
]
};

trustedDomains.config_show_access_token = {
domains: [
'https://[user_domain].zitadel.cloud',
'https://[user_domain].zitadel.cloud/oauth/v2/token',
'http://localhost:3000',
'http://localhost:3000/workloads',
], showAccessToken: true,
};

Versions

react-oidc 7.23.1

Expected

access token reachable in code

Actual

Access token still secured by OidcServiceWorker and can't be reached.

i.e. on http://localhost:3000/workloads:

const { accessToken } = useOidcAccessToken();
console.log(accessToken)

returns ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER_default_default

I need to get it, to post the token to another service as part of configuration data.

@guillaume-chervet
Copy link
Contributor

guillaume-chervet commented Dec 8, 2024

hi @JevgeniF ,

juste use

const { accessToken } = useOidcAccessToken("config_show_access_token");
console.log(accessToken)

then it will work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants