Segfault when using QAbstractOAuth::setModifyParametersFunction

Phil Thompson phil at riverbankcomputing.com
Fri May 14 12:11:38 BST 2021


On 11/05/2021 19:21, Bryce Beagle wrote:
> Hi, I'm trying to implement OAuth 2.0 Authorization Code Flow with PKCE 
> in
> my PyQt application and am having trouble making use of
> QAbstractOAuth::modifyParametersFunction in my 
> QOAuth2AuthorizationCodeFlow
> subclass.
> 
>>>> print(self.modifyParametersFunction)
> <built-in method modifyParametersFunction of CognitoOAuthFlow object at
> 0x7f8ea0162b80>
> 
>>>> print(self.modifyParametersFunction())
> SystemError: <built-in method modifyParametersFunction of 
> CognitoOAuthFlow
> object at 0x7f8ea0162b80> returned NULL without setting an error
> 
> This isn't *too* surprising as this function pointer should be set to 
> NULL
> within Qt until QAbstractOAuth::setModifyParametersFunction is called, 
> but
> I would expect it to have a more elegant PyQt return value (such as a
> Python None), or to throw a more descriptive error.

That should be fixed in the next snapshot.

> However, and this is causing my issues, I can't figure out how to 
> actually
> use QAbstractOAuth::setModifyParametersFunction properly.
> 
>>>> def modifyParamsFunction(stage: QAbstractOAuth.Stage, parameters: 
>>>> dict):
> ...     if stage is QAbstractOAuth.RequestingAuthorization:
> ...         parameters["identity_provider"] = "COGNITO"
> ...         parameters["code_challenge_method"] = "S256"
> ...         ...  # other stuff
>>>> class CognitoOAuthFlow(QOAuth2AuthorizationCodeFlow):
> ...     def __init__(*args, **kwargs):
> ...         ...
> ...         self.setModifyParametersFunction(modifyParamsFunction)
> 
> When I try using CognitoOAuthFlow.grant() (after setting up my
> URLs/scopes/identifiers/etc.), I get a segfault.
> 
> Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
> 
> Is there something I'm missing here? If necessary, I can try to provide 
> a
> more complete example, but it might require me to include information 
> about
> our authorization flow.

Can you send me something I can run privately - I know nothing about 
OAuth.

Thanks,
Phil


More information about the PyQt mailing list