def __init__()

in src/olympia/devhub/forms.py [0:0]


    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        super().__init__(*args, **kwargs)
        self.action = self.data.get('action', None)
        self.available_actions = []

        # Available actions determine what you can do currently
        has_credentials = self.credentials is not None
        has_confirmation = self.confirmation is not None

        # User has credentials, show them and offer to revoke/regenerate
        if has_credentials:
            self.fields['credentials_key'] = forms.CharField(
                label=_('JWT issuer'),
                max_length=255,
                disabled=True,
                widget=forms.TextInput(attrs={'readonly': True}),
                required=True,
                initial=self.credentials.key,
                help_text=_(
                    'To make API requests, send a <a href="{jwt_url}">'
                    'JSON Web Token (JWT)</a> as the authorization header. '
                    "You'll need to generate a JWT for every request as explained in "
                    'the <a href="{docs_url}">API documentation</a>.'
                ).format(
                    jwt_url='https://self-issued.info/docs/draft-ietf-oauth-json-web-token.html',
                    docs_url='https://addons-server.readthedocs.io/en/latest/topics/api/auth.html',
                ),
            )
            self.fields['credentials_secret'] = forms.CharField(
                label=_('JWT secret'),
                max_length=255,
                disabled=True,
                widget=forms.TextInput(attrs={'readonly': True}),
                required=True,
                initial=self.credentials.secret,
            )
            self.available_actions.append(self.ACTION_CHOICES.revoke)

            if has_confirmation and self.confirmation.confirmed_once:
                self.available_actions.append(self.ACTION_CHOICES.regenerate)

        elif has_confirmation:
            get_token_param = self.request.GET.get('token')

            if (
                self.confirmation.confirmed_once
                or get_token_param is not None
                or self.data.get('confirmation_token') is not None
            ):
                help_text = _(
                    'Please click the confirm button below to generate '
                    'API credentials for user <strong>{name}</strong>.'
                ).format(name=self.request.user.name)
                self.available_actions.append(self.ACTION_CHOICES.generate)
            else:
                help_text = _(
                    'A confirmation link will be sent to your email address. '
                    'After confirmation you will find your API keys on this page.'
                )

            self.fields['confirmation_token'] = forms.CharField(
                label='',
                max_length=20,
                widget=forms.HiddenInput(),
                initial=get_token_param,
                required=False,
                help_text=help_text,
                validators=[self.validate_confirmation_token],
            )

        else:
            if waffle.switch_is_active('developer-submit-addon-captcha'):
                self.fields['recaptcha'] = ReCaptchaField(
                    label='', help_text=_("You don't have any API credentials.")
                )
            self.available_actions.append(self.ACTION_CHOICES.confirm)