hi i am developing Twitter client on iPhone, here i am using MGTwitter library and OAuthentication, i am Authenticating(sign in) and Getting Request Token,
My problem is, when i send request i am getting error
Request 8DC1F854-0F16-40BF-85EC-669AF0B25FCE failed with error: Error Domain=HTTP Code=401 "The operation couldn’t be completed. (HTTP error 401.)"
how i have to solve this error
Please tell me
Thank you
The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource.
The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource. The server generating a 401 response MUST send a WWW-Authenticate header field containing at least one challenge applicable to the target resource.
A 401 Authorization Required error means you can try accessing the resource again using the correct credentials. In other words, it's often a temporary problem, unlike an HTTP 403 error in which you're expressly forbidden to access the page you're hoping to reach.
What worked for me: Go to your twitter app and in Settings set Application Type to "Read and Write".
Now i tried this and the app still gave me the same error. I then opened my twitter account ( the one you are using to login). Click on Settings and Applications and check what the access is against the app that you've made. In case it is Read only, revoke access, go to your iPhone simulator and Reset Content and Settings (you can do this by clicking iOS Simulator on the menu on top of your screen) . Compile the program again and try checking the Reads-Write access in your twitter account now.
This worked for me because basically when i ran the program for the first time, the Application Type was set to Read Only. Changing the Application Type after that doesn't make a difference.
ps: I left the Callback URL blank.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With