Home>

As mentioned above, the payload value cannot be obtained with request.form in the following test code.
ImmutableMultiDict ([]) returns empty.
Can you tell me if there are any points to check because I do not know even after debugging many times?

python

def test_grant_type (app):
    path = '/ oauth/token'
    payload = {'grant_type': 'client_credentials', 'scope': 'test_user'}
    auth_header = "client_id: client_secret"
    b64val = base64.b64encode (auth_header.encode ('UTF-8'))
    headers = {'Authorization': 'Basic% s'% b64val.decode ('UTF-8')}
    with app.test_request_context (path, method = "POST") as req:
        req.request.args = payload
        req.request.headers = headers
    import pdb;
    pdb.set_trace ()
    client_id = "test_user"
    assert "test_account_id" == get_grant_type (req.request, client_id)

Error

>/Users/t/local/c/tests/auth.py (149) test_grant_type ()
->client_id = "test_user"
(Pdb) p req.request.form
ImmutableMultiDict ([])
(Pdb) p request
<Request 'http: // localhost /' [GET]>
(Pdb) p req.request
<Request 'http: // localhost/oauth/token' [POST]>
(Pdb) p req.request.args
{'grant_type': 'client_credentials', 'scope': 'test_user'}