there are two main way to login
use selenium ==>for SSO, oracle will reject this behavior. "
System error. Please re-try your action. If you continue to get this error, please contact the Administrator.
"import requests
import sys
import io
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8')
cap = DesiredCapabilities().FIREFOX
cap["marionette"] = False
browser = webdriver.Firefox()
url2 = 'xxx'
browser.get(url2)browser.implicitly_wait(300)
username = browser.find_element_by_id('sso_username')
username.send_keys('xxxx')
password = browser.find_element_by_id('ssopassword')
password.send_keys('xxxx')
student = browser.find_elements_by_link_text('Sign In')
student.click()
browser.get(url2)
browser.save_screenshot('picture1.png')
print(browser.page_source.encode('utf-8').decode())
browser.quit()
#/bin/python
import sys
from lxml import etree
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
s = requests.session()
s.trust_env = False # fastercookie = Noneusername = 'username'password = 'pwd'def login():
header = {'User-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
'Connection':'keep-alive'}
form_data = {'ssousername':'xxxx',
'password':'xxxxx'}
"""1. give get http request to server2. redirect to login url3. send back http response4. from respnose.cookies to get request id, from response.content to get token.5. use request id, token and account to create a form data, give post http request to server6. server to authetication, validate the session.7. that session can be used to go to any urls now."""
goto_url='xxxxx'
login_url = 'xxxxx'
print('login...')
res = s.get(goto_url, headers=header, verify=False)
cookie = res.cookies
for key in res.cookies.get_dict():
if key.startswith('OAM_REQ_ID_'):
form_data['request_id'] = key.replace('OAM_REQ_ID_', '')
#from http response body, to get token.
form_data['site2pstoretoken'] = str(etree.HTML(res.content).xpath('//input[@name="site2pstoretoken"]/@value')[0])
form_data['OAM_REQ'] = str(etree.HTML(res.content).xpath('//input[@name="OAM_REQ"]/@value')[0])
res = s.post(login_url, headers=header, params=form_data, allow_redirects=False, verify=False)
cookie = res.cookies
print("post login params to{0}, http status{1}, cookie :{2}".format(login_url, res.status_code, cookie))
print(cookie.get_dict())
res = s.get(goto_url, headers=header, verify=False)
print res.content