mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-18 16:11:34 +03:00
27 lines
2.6 KiB
HTML
27 lines
2.6 KiB
HTML
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># Authentication with:</span>
|
|
<span class="line"></span><span class="comment"># username=bob@email.com</span>
|
|
<span class="line"></span><span class="comment"># password=secret</span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># the '@' must be url-escaped</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://bob%40email.com:secret@localhost:8000/basic-authentication-per-request</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
|
<span class="multiline"><span class="line">```You are authenticated```</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span><span class="comment"># Header value can be computed with `echo -n 'bob@email.com:secret' | base64`</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/basic-authentication-per-request</span></span>
|
|
<span class="line"><span class="string">Authorization</span><span>:</span> <span class="string">Basic Ym9iQGVtYWlsLmNvbTpzZWNyZXQ=</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
|
<span class="multiline"><span class="line">```You are authenticated```</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span><span class="comment"># We can also use a BasicAuth section to specify user and password</span>
|
|
<span class="line"></span><span class="comment"># without any base64 encoding.</span>
|
|
<span class="line"></span><span class="comment"># Note that spaces surrounded user and password are trimmed. If you</span>
|
|
<span class="line"></span><span class="comment"># really want a space in your password (!!), you could use Hurl</span>
|
|
<span class="line"></span><span class="comment"># unicode literal \u{20}.</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/basic-authentication-per-request</span></span>
|
|
<span class="line section-header">[BasicAuth]</span>
|
|
<span class="line"><span class="string">bob@email.com</span><span>:</span> <span class="string">secret</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
|
<span class="multiline"><span class="line">```You are authenticated```</span></span>
|
|
</span></span></code></pre>
|