Hi Ashok,

When using xAuth, it's required that you use HTTP-header based OAuth rather
than query parameter based OAuth. It appears that you are mixing both
together in these requests -- using both query-string based OAuth and header
based OAuth. Your request URI should only include:
https://api.twitter.com/oauth/access_token and nothing else.

Here's a handy checklist of things to remember with xAuth:
  - You must be using HTTP headers for the OAuth Authorization
  - You must be using POST as your method
  - You must be using SSL
  - Your POST body must contain the x_auth_* parameters as standard
application/x-www-form-urlencoded parameters
  - Your Content-Type should be set to "application/x-www-form-urlencoded"
  - If the logins or passwords you are sending have non-url-safe characters,

they should be URL encoded in your POST body and encoded again in your
signature base string (just like any OAuth request)

Taylor Singletary
Developer Advocate, Twitter
http://twitter.com/episod


On Wed, May 19, 2010 at 1:11 PM, asho...@huawei.com <ashok.c...@gmail.com>wrote:

> Hi,
>
> I tried to use xAuth. and facing the below exception. Can u please
> help finding the issue.
>
> Thanks
> Ashok
>
>
> 05-20 01:36:48.582: INFO/AccessToken(530):
>
> x_auth_username=sahuashok&x_auth_mode=client_auth&oauth_version=1.0&oauth_nonce=516625b7-
> d264-434f-856f-a2bf3a1bb7b6&oauth_signature_method=HMAC-
>
> SHA1&oauth_consumer_key=4nh2gyegnLIao9MqXZB9Ng&x_auth_password=ashoksahu&oauth_timestamp=1274299608
> 05-20 01:36:48.582: INFO/AccessToken(530):
>
> https://api.twitter.com/oauth/access_token?x_auth_username=sahuashok&x_auth_mode=client_auth&oauth_version=1.0&oauth_nonce=516625b7-d264-434f-856f-a2bf3a1bb7b6&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=4nh2gyegnLIao9MqXZB9Ng&x_auth_password=ashoksahu&oauth_timestamp=1274299608
> 05-20<https://api.twitter.com/oauth/access_token?x_auth_username=sahuashok&x_auth_mode=client_auth&oauth_version=1.0&oauth_nonce=516625b7-d264-434f-856f-a2bf3a1bb7b6&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=4nh2gyegnLIao9MqXZB9Ng&x_auth_password=ashoksahu&oauth_timestamp=1274299608
> 05-20> 01:36:48.602: INFO/AccessToken(530): POST
> 05-20 01:36:48.652: INFO/AccessToken(530): OAuth
>
> oauth_consumer_key="4nh2gyegnLIao9MqXZB9Ng",oauth_nonce="255f2c88-1125-401c-
> a86e-ec3e3f50b039",oauth_signature_method="HMAC-
>
> SHA1",oauth_timestamp="1274299608",oauth_version="1.0",oauth_signature="%5BB
> %4043d04910"
> 05-20 01:36:52.551: INFO/Errorcode=(530): 401
> 05-20 01:36:52.561: INFO/Errorcode=(530): [Ljava.lang.String;@43d442c0
> 05-20 01:36:52.561: WARN/System.err(530): java.io.IOException:
> Received authentication challenge is null
> 05-20 01:36:52.588: WARN/System.err(530):     at
>
> org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequestInternal(HttpURLConnection.java:
> 1596)
> 05-20 01:36:52.591: WARN/System.err(530):     at
>
> org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequest(HttpURLConnection.java:
> 1551)
> 05-20 01:36:52.617: WARN/System.err(530):     at
>
> org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:
> 1273)
> 05-20 01:36:52.621: WARN/System.err(530):     at
>
> org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection.getResponseCode(HttpsURLConnection.java:
> 116)
> 05-20 01:36:52.621: WARN/System.err(530):     at
> com.sahu.TestxAuth.AccessToken.request(AccessToken.java:100)
> 05-20 01:36:52.632: WARN/System.err(530):     at
> com.sahu.TestxAuth.AccessToken.mainEntry(AccessToken.java:75)
> 05-20 01:36:52.632: WARN/System.err(530):     at
> com.sahu.TestxAuth.TestxAuth.onCreate(TestxAuth.java:13)
> 05-20 01:36:52.632: WARN/System.err(530):     at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> 1047)
> 05-20 01:36:52.632: WARN/System.err(530):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2431)
> 05-20 01:36:52.632: WARN/System.err(530):     at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> 2484)
> 05-20 01:36:52.632: WARN/System.err(530):     at
> android.app.ActivityThread.access$2200(ActivityThread.java:119)
> 05-20 01:36:52.641: WARN/System.err(530):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1835)
> 05-20 01:36:52.641: WARN/System.err(530):     at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 05-20 01:36:52.641: WARN/System.err(530):     at
> android.os.Looper.loop(Looper.java:123)
> 05-20 01:36:52.641: WARN/System.err(530):     at
> android.app.ActivityThread.main(ActivityThread.java:4325)
> 05-20 01:36:52.666: WARN/System.err(530):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> 05-20 01:36:52.671: WARN/System.err(530):     at
> java.lang.reflect.Method.invoke(Method.java:521)
> 05-20 01:36:52.691: WARN/System.err(530):     at
> com.android.internal.os.ZygoteInit
> $MethodAndArgsCaller.run(ZygoteInit.java:860)
> 05-20 01:36:52.691: WARN/System.err(530):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
> 05-20 01:36:52.691: WARN/System.err(530):     at
> dalvik.system.NativeStart.main(Native Method)
> 05-20 01:36:53.011: INFO/ActivityManager(52): Displayed activity
> com.sahu.TestxAuth/.TestxAuth: 5371 ms (total 5371 ms)
>

Reply via email to