Skip to content

Commit 1ff5b03

Browse files
committed
updated documentation for setBasicAuth contrib
1 parent fcbaf0b commit 1ff5b03

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Who is Using It?
4242
[Pose](https://market.android.com/details?id=com.pose)
4343
: Pose is the #1 fashion app for sharing and discovering new styles
4444

45+
[Pocket Salsa](https://play.google.com/store/apps/details?id=com.addicted2salsa.pocketsalsa&hl=en)
46+
: Pocket Salsa is the easiest way to learn how to dance salsa.
47+
4548
Send me a [message](https://github.com/inbox/new?to=loopj) on github to let me
4649
know if you are using this library in a released android application!
4750

@@ -193,6 +196,27 @@ RequestParams params = new RequestParams(paramMap);
193196
See the [RequestParams Javadoc](http://loopj.com/android-async-http/doc/com/loopj/android/http/RequestParams.html)
194197
for more information.
195198

199+
Adding HTTP Basic Auth credentials
200+
------------------------------------
201+
Some requests may need username/password credentials when dealing with API services that use HTTP Basic Access Authentication requests.
202+
You can use the method `setBasicAuth()` to provide your credentials.
203+
204+
Set username/password for any host and realm for a particular request. By default the Authentication Scope is for any host, port and realm.
205+
{% highlight java %}
206+
AsyncHttpClient client = new AsyncHttpClient();
207+
client.setBasicAuth("username","password/token");
208+
client.get("http://example.com".....); //etc.
209+
{% endhighlight %}
210+
211+
You can also provide a more specific Authentication Scope (recommended)
212+
{% highlight java %}
213+
AsyncHttpClient client = new AsyncHttpClient();
214+
client.setBasicAuth("username","password", new AuthScope("example.com",80, AuthScope.ANY_REALM));
215+
client.get("http://example.com".....); //etc.
216+
{% endhighlight %}
217+
218+
See the [RequestParams Javadoc](http://loopj.com/android-async-http/doc/com/loopj/android/http/AsyncHttpClient.html)
219+
for more information.
196220

197221
Uploading Files with `RequestParams`
198222
------------------------------------
@@ -262,6 +286,8 @@ The Droid Fu Project (<https://github.com/kaeppler/droid-fu>)
262286
Rafael Sanches (<http://blog.rafaelsanches.com>)
263287
: Original `SimpleMultipartEntity` code
264288

289+
Anthony Persaud (<http://github.com/apersaud>)
290+
: Added support for HTTP Basic Authentication requests.
265291

266292
License
267293
-------

0 commit comments

Comments
 (0)