#NEWLINE# def discover_endpoints( me ) : #NEWLINE# #INDENT# me_response = requests . get ( me ) #NEWLINE# if ( me_response . status_code != 200 ) : #NEWLINE# #INDENT# return make_response ( 'Unexpected response from URL: {}' . format ( me_response ) , 400 ) #NEWLINE# #UNINDENT# soup = bs4 . BeautifulSoup ( me_response . text ) #NEWLINE# auth_endpoint = soup . find ( 'link' , { #NEWLINE# #INDENT# 'rel' : 'authorization_endpoint' , #NEWLINE# #UNINDENT# } ) #NEWLINE# token_endpoint = soup . find ( 'link' , { #NEWLINE# #INDENT# 'rel' : 'token_endpoint' , #NEWLINE# #UNINDENT# } ) #NEWLINE# micropub_endpoint = soup . find ( 'link' , { #NEWLINE# #INDENT# 'rel' : 'micropub' , #NEWLINE# #UNINDENT# } ) #NEWLINE# return ( ( auth_endpoint and auth_endpoint [ 'href' ] ) , ( token_endpoint and token_endpoint [ 'href' ] ) , ( soup and micropub_endpoint [ 'href' ] ) )