Twitter authentication : 403 Forbidden: The server understood the request, but is refusing to fulfill it
Ok. I got it working. I was not redirecting to authorize url correctly. Here is the modified code.
if(!isset($_GET['oauth_token'])){
$requestToken = $twitterOauthObj->getRequestToken();
$_SESSION["oauth_token"] = $requestToken["oauth_token"];
$_SESSION["oauth_token_secret"] = $requestToken["oauth_token_secret"];
header("Location:".$twitterOauthObj->getAuthorizeURL($requestToken["oauth_token"]));
}
Thank you guys for all your valuable suggestions. Really appreciate it!!
Related videos on Youtube
user1430878
Updated on June 13, 2022Comments
-
user1430878 almost 2 years
I am trying to authenticate user using OAuth and retrieve the user data. When the user is not signed into twitter the authentication works and I am able to get the user details. But if the user is already signed in on twitter I am getting this error message '403 Forbidden: The server understood the request, but is refusing to fulfill it.' . In some posts they said to make all the requests through https instead of http. That I have done. I have downloaded the code for authentication from 'http://net.tutsplus.com/tutorials/php/how-to-authenticate-users-with-twitter-oauth/' . Please help.
$twitterOauthObj = new TwitterOAuth($oauth_consumer_key, $oauth_consumer_secret); if(!isset($_GET['oauth_token'])){ $requestTokenArray = $twitterOauthObj->getRequestToken($callback_url); $requestToken = $requestTokenArray['oauth_token']; $tokenSecret = $requestTokenArray['oauth_token_secret']; $authorizeUrl = $twitterOauthObj->getAuthorizeURL($requestToken); $response = $twitterOauthObj->oAuthRequest($authorizeUrl, 'GET', $requestTokenArray); print_r($response); } else{ $oauthToken = $_GET['oauth_token']; $requestToken = $oauthToken; $oauthVerifier = $_GET['oauth_verifier']; $accessTokenArray = $twitterOauthObj->getAccessToken($oauthVerifier, $oauthToken); $oauthToken = $accessTokenArray['oauth_token']; $oauthTokenSecret = $accessTokenArray['oauth_token_secret']; $userTwitterId = $accessTokenArray['user_id']; $screenName = $accessTokenArray['screen_name']; }
-
user1430878 over 11 yearsIs it ok if i keep my callback url http and not https? Somebody please help me.
-