I have a python pyramid application with multiple resources, Each resource if its not authenticated need to be redirected to a 3rd party for authentication. The 3rd party(once authenticated) will redirect to a callback URL that I use to extract the user information, once I extract the userinformation I will redirect to the redirect_url that is set in the cookie. I see request.set_cookie is a kind of duplicate code for accessing each resource. Is there a better way to handle this?
def resource_1(request)
response = HTTPSeeOther(location="/oauth2")
response.set_cookie('redirect_url', request.url)
return response
def resource_2(request)
response = HTTPSeeOther(location="/oauth2")
response.set_cookie('redirect_url', request.url)
return response