def authorize(self, code): """Complete the web authorization flow and return the refresh token. :param code: The code obtained through the request to the redirect uri. :returns: The obtained refresh token, if available, otherwise ``None``. The session's active authorization will be updated upon success. """ authenticator = self._reddit._read_only_core._authorizer._authenticator authorizer = Authorizer(authenticator) authorizer.authorize(code) authorized_session = session(authorizer) self._reddit._core = self._reddit._authorized_core = authorized_session return authorizer.refresh_token
def authorize(self, code): """Complete the web authorization flow and return the refresh token. :param code: The code obtained through the request to the redirect uri. :returns: The obtained refresh token, if available, otherwise ``None``. The session's active authorization will be updated upon success. """ authenticator = self._reddit._read_only_core._authorizer._authenticator if not isinstance(authenticator, TrustedAuthenticator) or \ self._reddit.config.username: raise ClientException('authorize can only be used with web apps.') authorizer = Authorizer(authenticator) authorizer.authorize(code) authorized_session = session(authorizer) self._reddit._core = self._reddit._authorized_core = authorized_session return authorizer.refresh_token