The remote server returned an error: (401) Unauthorized


#1

Server Error in ‘/Demo-OMP’ Application.
The remote server returned an error: (401) Unauthorized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Source Error:

Line 273: finally
Line 274: {
Line 275: webRequest.GetResponse().GetResponseStream().Close();
Line 276: responseReader.Close();
Line 277: responseReader = null;

Source File: c:\Inetpub\wwwroot\Demo-OMP\App_Code\oAuthTwitter.cs Line: 275


#2

Your request is being rejected because there’s an invalid or no authorization context. How are you passing authorization information?


#3

same is happned with me.

I make 150 request only per hour.

Is there solution for it?


#4

I got the same problem. my clinet used to work fine and it gets 401 Unauthorized now.

it seems the oauth_token/Access token of my app is denied.

If I try to open the authorize url, it returns "The request token for this page is invalid. It may have already been used, or expired because it is too old. Please go back to the site or application that sent you here and try again; it was probably just a mistake. "

I try some other app’s authorize api url with oauth token. some of them is working fine and ask for authrize app.

Anyone can help me?

my app’s authorize url:
https://api.twitter.com/oauth/authorize?oauth_token=561901232-CBZywiSG2zVo7btPLVx9wzrRlgFxqsRkLguJAauP

a working url from another app:
https://api.twitter.com/oauth/authorize?oauth_token=O8dOyrJ3pF1AJfXD84kelhrI4oXunDJNmHORg0jEtg


#5

The first URL you show does not have a request token being sent to oauth/authorize – that’s an access token (you can tell because it has a user ID in the string). You must have some bug in your OAuth process right now that’s re-using an existant access token on the authorize step when you should be using the request token you received from oauth/authorize


#6

I’m experiencing a similar issue. Everything was working just fine and now I am getting the following error.

TwitterAPIException: Exception of type ‘TwitterAPIException’ was thrown. —> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at TwitterVB2.TwitterOAuth.WebRequest(Method RequestMethod, String Url, String PostData)
— End of inner exception stack trace —
at TwitterVB2.TwitterOAuth.WebRequest(Method RequestMethod, String Url, String PostData)
at TwitterVB2.TwitterOAuth.OAuthWebRequest(Method RequestMethod, String url, String PostData)
at TwitterVB2.TwitterAPI.PerformWebRequest(String Url, String HTTPMethod)
at TwitterVB2.TwitterAPI.Update(String Text)

Nothing has changed. I am able to log into our website using the same API information. So any help on this matter would be greatly appreciated.


#7

Anyone fix this? We have the same problem, everything was working fine and then it just stopped

“Whoa there!
The request token for this page is invalid. It may have already been used, or expired because it is too old. Please go back to the site or application that sent you here and try again; it was probably just a mistake.”


#8

I have created another test app with different settings to see if it can work. Unfortunately, it did not.


#9

same the issue, any body share to fix this?


#10

any Twitter developers care to tell us how to fix this problem?

I am using the out of the box MVC4 Twitter login with a new Twitter application (tried twice) and I’m getting 401.


#11

Anything?


#12

Please help regarding 401


#13

where are twitter developers ?


#14

Please explain in detail,how i can pass…


#15

I


#16

Im also getting same problem help me Twitter Developers … W R U

The remote server returned an error: (401) Unauthorized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Source Error:

Line 294: finally
Line 295: {
Line 296: webRequest.GetResponse().GetResponseStream().Close();
Line 297: responseReader.Close();
Line 298: responseReader = null;

Source File: g:\TwitterLoginForWebSite\App_Code\oAuthTwitter.cs Line: 296

Stack Trace:

[WebException: The remote server returned an error: (401) Unauthorized.]
System.Net.HttpWebRequest.GetResponse() +6040131
oAuthExample.oAuthTwitter.WebResponseGet(HttpWebRequest webRequest) in g:\TwitterLoginForWebSite\App_Code\oAuthTwitter.cs:296
oAuthExample.oAuthTwitter.WebRequest(Method method, String url, String postData) in g:\TwitterLoginForWebSite\App_Code\oAuthTwitter.cs:268
oAuthExample.oAuthTwitter.oAuthWebRequest(Method method, String url, String postData) in g:\TwitterLoginForWebSite\App_Code\oAuthTwitter.cs:223
TwitterAuthentication.GetUserDetailsFromTwitter() in g:\TwitterLoginForWebSite\TwitterAuthentication.aspx.cs:35
TwitterAuthentication.Page_Load(Object sender, EventArgs e) in g:\TwitterLoginForWebSite\TwitterAuthentication.aspx.cs:19
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207


#17

The remote server returned an error: (401) Unauthorized.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Source Error:

Line 294: finally
Line 295: {
Line 296: webRequest.GetResponse().GetResponseStream().Close();
Line 297: responseReader.Close();
Line 298: responseReader = null;

Please help how to provide authorization information with explanation.


#18

Hi Nirmal,

I am not sure you found fix for it or not but below link helped me out so thought of sharing it with you.

Regards,
Nipam Patel


#19

Hi Guys,

I am not sure you found fix for it or not but below link helped me out so thought of sharing it with you.

Regards,
Nipam Patel


#20

I’ve just encountered the same problem here using ASP.NET MVC 4. The solution which worked for me was that I needed to provide some random “Callback URL” in the “Settings” tab of my twitter application. For example: http://www.website.com