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

Debug OIDC Token #219

Open
gregelin opened this issue Apr 9, 2022 · 0 comments
Open

Debug OIDC Token #219

gregelin opened this issue Apr 9, 2022 · 0 comments

Comments

@gregelin
Copy link
Contributor

gregelin commented Apr 9, 2022

        token_payload = {
            'client_id': self.OIDC_RP_CLIENT_ID,
            'client_secret': self.OIDC_RP_CLIENT_SECRET,
            'grant_type': 'authorization_code',
            'code': code,
            'redirect_uri': absolutify(
                self.request,
                reverse(reverse_url))
        }
        token_payload.update(self.get_settings('OIDC_AUTH_REQUEST_EXTRA_PARAMS', {}))
        # DEBUG
        LOGGER.warning(f"(1) type token_payload, {type(token_payload)}")
        LOGGER.warning(f"(1) type client_id, {type(token_payload.get('client_id', None))}, {token_payload.get('client_id', None)}")
        # Get the token
        token_info = self.get_token(token_payload)
        id_token = token_info.get('id_token')
        access_token = token_info.get('access_token')
        # DEBUG
        LOGGER.warning(f"(1) type id_token, {type(token_payload.get('id_token', None))}, {token_payload.get('id_token', None)}")
        LOGGER.warning(f"(1) type access_token, {type(access_token)}, {access_token}")

        # Validate the token
        payload = self.verify_token(id_token, nonce=nonce)
        # DEBUG
        LOGGER.warning(f"(1) type payload, {type(payload)}, {payload}")

        if payload:
            if type(payload) == type(dict()):
                import json
                payload = json.dumps(payload)
                LOGGER.warning(f"(2) type payload , {type(payload)}, {payload}")
                # if 'SessionToken' in payload:
                #     access_token = payload.get('SessionToken', None)# DEBUG
                #     LOGGER.warning(f"(2) type access_token , {type(access_token)}, {access_token}")

            self.store_tokens(access_token, id_token)
            try:
                return self.get_or_create_user(access_token, id_token, payload)
            except SuspiciousOperation as exc:
                LOGGER.warning('failed to get or create user: %s', exc)
                return None
        return None

image

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

1 participant