使用OAuth2的API上的RequestsLibrary

问题描述 投票:0回答:1

我正在尝试在使用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

任何帮助将不胜感激。

oauth-2.0 robotframework
1个回答
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}
© www.soinside.com 2019 - 2024. All rights reserved.