[英]how to get access token from created session using robot testing framework
Hi here is my script file.I would like to get access token from created session.I tried this way but I am getting access token as none.Can any help me. 嗨,这是我的脚本文件。我想从创建的会话中获取访问令牌。我尝试过这种方式,但我获取的访问令牌为none。
Create Session httpbin ${server_URL} verify=${True}
&{dict} Create Dictionary username=${username} password=${password} email=${email} role=${role}
${header} Create Dictionary Content-Type=application/json charset=UTF-8
${resp} Post Request httpbin /api/Owners data=${dict} headers=${header}
${accessToken}= evaluate $resp.json().get("access_token")
Log to Console ${accessToken}
log Many ${resp.text}
${id} Evaluate $resp.json().get("id")
Log ${id}
log to console ${resp.status_code}
${resp} Get Request httpbin uri=/api/Owners?access_token=${accessToken}
${resp} Get Substring ${resp.text} 1 -1
Log ${resp}
${json_str} Convert JSON To String ${resp}
Should Contain ${json_str} ${id}
using requests i will try to login and create an Token 使用请求,我将尝试登录并创建令牌
import requests
login = {
"user" : "username",
"pass" : "passwrod",
}
here Write your own Token that is only an Example 在这里写你自己的令牌仅仅是一个例子
accesToken = {
"Accept" : "application/json",
}
request = requests.post('http://www.web.com/user', data=login, headers=accesToken')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.