retrieve authorization code to get access token

def retrieve_authorization_code(self, redirect_func=None):
        """ retrieve authorization code to get access token
        """
        
        request_param = {
            "client_id": self.client_id,
            "redirect_uri": self.redirect_uri,
            }

        if self.scope:
            request_param['scope'] = self.scope

        if self._extra_auth_params:
            request_param.update(self._extra_auth_params)

        r = requests.get(self.auth_uri, params=request_param,
                         allow_redirects=False)
        url = r.headers.get('location') 
        if self.local:
            webbrowser.open_new_tab(url)
            authorization_code = raw_input("Code: ")
            if self.validate_code(authorization_code):
                self.authorization_code = authorization_code
        else:
            return redirect_func(url)