def callback(self, response, session, format='dict'):
        """
        This is the method that should be called when an AuthN response has been
        received from the OP.

        :param response: The URL returned by the OP
        :return:
        """
        if self.behaviour["response_type"] == 'code':
            respcls = AuthorizationResponse
        else:
            respcls = AccessTokenResponse

        try:
            authresp = self.parse_response(respcls, response,
                                           sformat=format, keyjar=self.keyjar)
        except ResponseError:
            logger.error("Could not parse response: '{}'".format(response))
            raise OAuth2Error("Problem parsing response")

        logger.info("{}: {}".format(respcls.__name__, authresp))

        if isinstance(authresp, ErrorResponse):
            if authresp["error"] == "login_required":
                return self.create_authn_request(session)
            else:
                raise OAuth2Error("Access denied")

        if session["state"] != authresp["state"]:
            self._err("Received state not the same as expected.")

        if self.behaviour["response_type"] == "code":
            # get the access token
            try:
                args = {
                    "code": authresp["code"],
                    "redirect_uri": self.registration_response[
                        "redirect_uris"][0],
                    "client_id": self.client_id,
                    "client_secret": self.client_secret,
                }

                try:
                    args['scope'] = response['scope']
                except KeyError:
                    pass

                atresp = self.do_access_token_request(
                    state=authresp["state"],
                    request_args=args,
                    authn_method=self.registration_response[
                        "token_endpoint_auth_method"])
                logger.info('Access token response: {}'.format(atresp))
            except Exception as err:
                logger.error("%s" % err)
                raise

            if isinstance(atresp, ErrorResponse):
                self._err('Error response: {}'.format(atresp.to_dict()))

            _token = atresp['access_token']
        else:
            _token = authresp['access_token']

        return {'access_token': _token}
dataset/ETHPy150Open rohe/pyoidc/src/oic/utils/rp/oauth2.py/OAuthClient.callback/original