How to use OAuth without authorization

  • Hi there,

    the Reddit API uses OAuth and I use QOAuth2AuthorizationCodeFlow to handle the user authorization, which works very well.

    However, I also want to implement userless OAuth, which is supported by Reddit to access the Reddit API read-only:

    In this case, there is no authorization step, the app just immediately requests the OAuth access token, like so:

    curl -H "Authorization: Basic $(echo -ne $REDDIT_CLIENT_ID | base64 --wrap 0)" -d 'device_id=DO_NOT_TRACK_THIS_DEVICE&grant_type=' -X POST

    Which will return a valid OAuth access token with read only scope.

    Is this possible with the Qt authorization library?

    Unfortunately the grant() method always tries to authorize with an user and the setStatus() method is private, so I cannot skip the authorization step.

    Any idea how I can use the Qt OAuth libraries to retrieve this userless access token?

    Any help is greatly appreciated :)

  • Lifetime Qt Champion


    What about subclassing QOAuth2AuthorizationCodeFlow and reimplement grant so that it does what you want ?

    In any case, it looks like it could be a missing use case in the module. You should check the bug report system to see if there's anything related.

Log in to reply