使用OAuth2的API上的RequestsLibrary

时间:2017-12-20 22:47:26

标签: oauth-2.0 robotframework

我正在尝试在使用OAUTH2身份验证的API上使用RequestsLibrary,但每次抛出400! = 200。

Get authToken

    Create Session   test   http://brentertainment.com/oauth2/
    ${data}=      Create Dictionary     grant_type= 'password'      client_id=demoapp     client_secret=demopass      username= 'demouser'   password='testpass'
    ${headers}=     Create Dictionary   Content-Type= 'application/x-www-form-urlencoded'
    ${resp}=  post request     test     /lockdin/token     ${headers}     ${data}
    Should Be Equal As Strings  ${resp.status_code}     200

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我使用扩展请求库而不是请求库

*** Settings ***
Library    ExtendedRequestsLibrary

*** Test Cases ***
Post Request With Password

    Create Password OAuth2 Session    member    http://token     client_id    client_secret    username   password    scope   base_url
    ${var} =  get request        member    /abc
    Log    ${var.content}