Access token request has been creating some problems since updates


#1

Hello,
I’ve been facing some difficulties on “Get Access Token” method. Error details below. The applications that I created after the last update produces that error. But the very same structure and code is working on the applications that I’ve created before the update. I’ve checked the same situation with different libraries, that doesn’t work either.

PS: If you update an old application’s detail now, that might not work also, just to let you know.

<?xml version="1.0" encoding="UTF-8"?> Invalid authorization header /oauth/access_token

#2

The error you are getting back suggests your authorization header is malformed. Could you share the header you are sending so we can take a look at what might be wrong.


#3

Thank you for your quick reply.

I’ve tried to authenticate with TweetSharp and Twitterizer .NET libraries. Here is a part of the code.

var requestToken = new OAuthRequestToken { Token = oauth_token };
TwitterService service = new TwitterService(TwitterConstants.ConsumerKey, TwitterConstants.ConsumerSecret);
OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);//This is the line that throws error


#4

In your code I can’t see a point where the user is directed to a webpage to authorize your application to act on their behalf. Is this handled by the line:

service.GetAccessToken


#5

This code is working after user grants permission to application. The code below will explain it much better.

public void AuthorizeCallback(string oauth_token, string oauth_verifier)
{
var requestToken = new OAuthRequestToken { Token = oauth_token };

	TwitterService service = new TwitterService(TwitterConstants.ConsumerKey, TwitterConstants.ConsumerSecret);
	OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);
	GetUserData(accessToken.Token, accessToken.TokenSecret, null);
}

#6

Edit: There is no change.


#7

You shouldn’t need to request a request token and go through the authorization steps if the user has already granted permission to the application.

The oauth_token and oauth_secret you receive from the final step of the OAuth flow (https://api.twitter.com/oauth/access_token) only expire if the user revokes your access to their account.

How do you store the accessToken after a user has authorized your application?


#8

Hello… I am getting the error Could not authenticate with OAuth. But i got the access tokn and access token secret correctly

Please help

   consumerKey     =   "************"
    consumerSecret  =   "************************"
   callbackUrl     =   "http://192.168.0.43:3334/test/test"
    apiURL          =   "https://api.twitter.com"
    
    request_token_path  =   "/oauth/request_token"
    access_token_path   =   "/oauth/access_token"
    authorize_path      =   "/oauth/authorize"
    
    @consumer           =   OAuth::Consumer.new(consumerKey,consumerSecret, {
                              :site => apiURL,
                              :scheme             => :header,
                              :http_method        => :post,
                              :request_token_path => request_token_path,
                              :access_token_path  => access_token_path,
                              :authorize_path     => authorize_path
                            })
     
    unless(params["oauth_token"].nil?)
        @request_token  =   session[:request_token]
        @access_token   =   @request_token.get_access_token
        @access_token   =   OAuth::AccessToken.new(@consumer,  @access_token.token, @access_token.secret)
        @tweets         =   @access_token.get('/1/account/verify_credentials')
        render :xml => @tweets.body
    else
        @request_token  =   @consumer.get_request_token(:oauth_callback => callbackUrl)
        firstUrl        =   @request_token.authorize_url(:oauth_callback => callbackUrl)
        session[:request_token] = @request_token
        redirect_to firstUrl
    end

#9

Hi,

I am trying to use tweetSharp in an ASP MVC 3 application. I am using the code in the example from github. It returns a 500 error when it goes to this line of my code in the authorizeCallback controller method:
OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

Does anyone have any idea what could be causing this and how to fix it?


#10

any one please give me the code for authentication of user using twitter step by step . I have tried using net.tutsplus.com and 9lessons.com.

I m using abrahms php outhand i m getting internal server error 500 exact call of function getRequestToken() of twitteroauth.php.


#11

Lorsque j’appuie sur le bouton authoriser l’application (à signer dans mon crm de twitter), je reçois cette erreur
Erreur du serveur DANS L’application ‘/’.

La Valeur etait trop grande ous trop petite Pour Un Int32.

Description: Une exception non Gerée S’est produite au moment de l’exécution de de la personal property actuelle Web. Contrôlez la trace de la pile verser Plus d’informations sur l’Erreur et fils origine de dans le code.

Détails de l’exception: System.OverflowException: La Valeur etait trop grande ous trop petite Pour Un Int32.

Erreur source:

Ligne 49: / / Étape 3 - Remplacer le jeton de demande pour un jeton d’accès
Ligne 50: service de TwitterService = new TwitterService (_consumerKey, _consumerSecret);
Ligne 51: OAuthAccessToken accessToken = service.GetAccessToken (requestToken, oauth_verifier);
Ligne 52: / / Étape 4 - authentifie l’utilisateur à l’aide du jeton d’accès
Ligne 53: service.AuthenticateWith (accessToken.Token, accessToken.TokenSecret);
PS: la ligne 51 est de couleur
Veuillez me répondre svpppp :frowning: