simple-linkedinphp: Undefined index: oauth - php

I'm using simple-linkedinphp and OAuth library to connect to LinkedIn. When I run demo.3.0.2.php, connect with LinkedIn and press the blue button "Ok, I'll allow" I get the error:
Notice: Undefined index: oauth on line 136.
LinkedIn->retrieveTokenAccess(): bad data passed, string type is required for $token, $secret and $verifier.
Examining the problem further it seems the session data is lost when LinkedIn returns to the script. cURL does seem to start a new session instead of using the initial session.

The following line in my config file caused the trouble:
ini_set("session.cookie_domain", ".mywebsite.com");
Commenting this out solved the problem.

Related

Yii2 OpenId Connect error - yii2-authclient returns 400 error "Token not provided" when I try to getUserAttributes()

I'm implementing OpenId Connect into my Yii2 app using the yii2-authclient library. I can login and exchange the code for a token with no problems. I've followed most of the code examples on the web and set a successCallback function that gets called once a user successfully logs in. It looks like this:
public function successCallback(ClientInterface $client)
{
$attributes = $client->getUserAttributes();
}
This code gets called, but calling getUserAttributes() results in the following error:
Exception – yii\authclient\InvalidResponseException
Request failed with code: 400, message:
{"error":"invalid_request","error_description":"Token not provided"}
The logs on the id server show a blank client and user, with an error of invalid_token.
I took a close look at the request I make and I see an access_token element. Any ideas what the problem might be? I can provide more information if necessary.
I figured it out. The problem was that the yii2-authclient library was sending the token as a GET parameter and the ID server was expecting it as a POST param. I upgraded the yii2-authclient library and that solved the problem since a recent change sends the parameter as POST instead of GET.

How to get twitter's user Access Token?

I am using https://twitteroauth.com/ in my some PHP pages. I want to get user access token and access secret token. I got my answer on this page: How to get user Access Token and Access Secret with the Twitter API using php
After replacing my consumer key and secret consumer key on both pages. I upload it on my server but then I got the following error when I open twitter-go.php
Fatal error: Uncaught exception `'Abraham\TwitterOAuth\TwitterOAuthException'` with message
'<?xml version="1.0" encoding="UTF-8"?>
<hash>
<error>Desktop applications only support the oauth_callback value 'oob'</error>
<request>/oauth/request_token</request>
</hash> '
in `/home/mediahyp/public_html/tweetme/twitteroauth/src/TwitterOAuth.php:138`
Stack trace:
#0 /home/mediahyp/public_html/tweetme/twitter-go.php(13): Abraham\TwitterOAuth\TwitterOAuth->oauth('oauth/request_t...', Array)
#1 {main} thrown in /home/mediahyp/public_html/tweetme/twitteroauth/src/TwitterOAuth.php on line 138
Can anyone tell me what is this error about? Am I missing something or something else.
https://twittercommunity.com/t/desktop-applications-only-support-the-oauth-callback-value-oob-oauth-request-token/252/2
The new interface simplifies this: if you provide a placeholder callback URL in the field for it in your application detail screen, it allows you to use dynamic callbacks. So just go ahead and put a placeholder in there (doesn't have to be the actual dynamic/runtime callback you use) and you'll be able to use other forms of auth.
When no placeholder is presented, the application is locked to OOB mode.

Freelancer API snowtigerlib Wrapper Class for PHP didn't work

I used snowtigerlib freelancer api, it is a php wrapper class. I downloaded the full code from this link
Then I setup SnowTigerLib_Config.inc file with my key and secret. Then I did the following step:
First it went to the following url.
Then I logged in to sandbox with my username and password.
Next step, it went the following url.
Here Authenticate API Access was authorized.
After Authorizing API access it went the following url
Here it shows that it is authorized and the automatically redirect into my callback url with following error:
ERROR
Notice: Undefined index: token in ..........\callback.php on line 4
HTTP Error: http_code:401 in ...............\SnowTigerLib.php on line 455
Details: http://api.sandbox.freelancer.com/RequestAccessToken/requestAccessToken.xml?oauth_consumer_key=7484ba1fdfa9138ec77ead0c881966ad43f194ba&oauth_nonce=5a9b4e19b1fcd551e416d8e1fa86ab50&oauth_signature=LKRcVWNRdE%2BIzAzem2svR%2F0OiG8%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1356949656&oauth_verifier=4a24c84d5b49465a51ca990e2114945894896ed6&oauth_version=1.0
Please give me reply if anybody knows this issue.

Error fetching OAuth2 access token : 500 Error

I am being randomly bugged by the following error message:
This occurs when php library tries to obtain the access token line 112.
Sometimes my code obtains access token in first try, sometimes I need to refresh the URL containing 'code' as get parameter multiple times before access token is obtained.
This error is coming frequently for last 3-4 days.
Fatal error:
Uncaught exception 'apiAuthException' with message 'Error fetching OAuth2 access token, message:
'<HTML> <HEAD> <TITLE>Error processing OAuth 2 request</TITLE> </HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Error processing OAuth 2 request</H1>
<H2>Error 500</H2>
</BODY> </HTML>
'' in /google-api-php-client-0.5.0/google-api-php-client/src/auth/apiOAuth2.php:105
Stack trace: #0 /google-api-php-client-0.5.0/google-api-php-client/src/apiClient.php(138): apiOAuth2->authenticate(Array)
#1 l.php(191): apiClient->authenticate()
#2 l.php(99): googoauthinit(true)
#3 {main} thrown in /google-api-php-client-0.5.0/google-api-php-client/src/auth/apiOAuth2.php on line 105
The code I use is directly lifted from here (EXACTLY same code with all parameters like app name, secret key, id etc correctly filled).
Also, tried registering new app but same error is received.
It might be a Google synchronization issue. Check out this Google Groups post and see if you have a similar issue.
I believe this issue is similar to this question on SO. You'll find the solution in the comments of the answer.
To disable at run time, you can use
$this->client->setClassConfig("Google_Http_Request", "disable_gzip",
true) as well.
This worked great for me.

Facebook application error- Access Token

I have made new Facebook application, and when I am trying to allow "post to profile", I am getting this error:
Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /home/mimota/public_html/gamingapp.com/test/src/base_facebook.php on line 1024
Thats part of the base_facebook.php file:
http://codeviewer.org/view/code:2263
I have marked there where is line 1024
I will really appriciate if some one could figure out whats wrong here, because I have no clue..
Thanks.
Use a URL of the following format to log into facebook:
https://graph.facebook.com/oauth/authorize?client_id=288229791195831&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup&scope=publish_stream,user_photos,read_stream,email
They will give you a token back which you will use when you send requests:
For example to see get the main photo URL use:
https://graph.facebook.com/me/picture&access_token=THE_TOKEN_YOU_GOT_BACK
To post to wall replace /me/picture with whatever you need to post (sth like /me/wall)

Categories