Google Actions: Account linking sends GET request to token URL - actions-on-google

I have some problems with the Account Linking for Google Actions:
I have implemented the OAuth2 steps described in the documentation by Google. I have implemented my OAuth2 server and tested it via Postman and am able to get an access token as expected.
If I try to authenticate from the Google Home app by adding the service to my account, I get taken to my authorization form, the authorization works fine and responds with an authorization code to Google's redirect URI as it is supposed to do. However Googles return URI says 'Account linking failed' and then I get a message in the Google Home app : 'Can't update the settings. Check your connection'.
Another strange thing that I've see from my logging of my Token URL script: I can see an incoming GET request from Google to my Token URL instead of a POST request with the required data as mentioned in the Google documentation. So even though the message 'Account linking failed' appears, it seems that Google is calling my token URL, but with a GET instead of a POST.
These are the logs of the requests to the token URL:
REQUEST FROM POSTMAN (testing software) > OK
__SERVER
Array
(
[USER] => www-data
[HOME] => /var/www
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_ACCEPT] => */*
[HTTP_USER_AGENT] => PostmanRuntime/7.6.1
[HTTP_POSTMAN_TOKEN] => f85664e2-7d38-4511-9519-cddda3feec06
[HTTP_CACHE_CONTROL] => no-cache
[HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded
[HTTP_CONTENT_LENGTH] => 145
[HTTP_CONNECTION] => close
[HTTP_HOST] => 127.0.0.1
[REDIRECT_STATUS] => 200
[SERVER_NAME] => _
[SERVER_PORT] => 80
[SERVER_ADDR] => 127.0.0.1
[REMOTE_PORT] => 38622
[REMOTE_ADDR] => 127.0.0.1
[SERVER_SOFTWARE] => nginx/1.12.2
[GATEWAY_INTERFACE] => CGI/1.1
[REQUEST_SCHEME] => http
[SERVER_PROTOCOL] => HTTP/1.0
[DOCUMENT_ROOT] => [******]
[DOCUMENT_URI] => /google/token/index.php
[REQUEST_URI] => /google/token/
[SCRIPT_NAME] => /google/token/index.php
[CONTENT_LENGTH] => 145
[CONTENT_TYPE] => application/x-www-form-urlencoded
[REQUEST_METHOD] => POST
[QUERY_STRING] =>
[SCRIPT_FILENAME] => [******]
[FCGI_ROLE] => RESPONDER
[PHP_SELF] => /google/token/index.php
[REQUEST_TIME_FLOAT] => 1553765980.9273
[REQUEST_TIME] => 1553765980
)
__POST
Array
(
[client_id] => [******]
[client_secret] => [******]
[grant_type] => authorization_code
[code] => [******]
)
REQUEST RECEIVED WHEN TESTING WITH GOOGLE HOME APP on smartphone > NOT OK
__SERVER
Array
(
[USER] => www-data
[HOME] => /var/www
[HTTP_ACCEPT_ENCODING] => gzip,deflate,br
[HTTP_USER_AGENT] => OpenAuth
[HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded
[HTTP_CONNECTION] => close
[HTTP_HOST] => 127.0.0.1
[REDIRECT_STATUS] => 200
[SERVER_NAME] => _
[SERVER_PORT] => 80
[SERVER_ADDR] => 127.0.0.1
[REMOTE_PORT] => 46184
[REMOTE_ADDR] => 127.0.0.1
[SERVER_SOFTWARE] => nginx/1.12.2
[GATEWAY_INTERFACE] => CGI/1.1
[REQUEST_SCHEME] => http
[SERVER_PROTOCOL] => HTTP/1.0
[DOCUMENT_ROOT] => [******]
[DOCUMENT_URI] => /google/token/index.php
[REQUEST_URI] => /google/token/
[SCRIPT_NAME] => /google/token/index.php
[CONTENT_LENGTH] =>
[CONTENT_TYPE] => application/x-www-form-urlencoded
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[SCRIPT_FILENAME] => [******]
[FCGI_ROLE] => RESPONDER
[PHP_SELF] => /google/token/index.php
[REQUEST_TIME_FLOAT] => 1553767309.7797
[REQUEST_TIME] => 1553767309
)
__REQUEST
Array
(
)
__POST
Array
(
)
__GET
Array
(
)
-------------------------
__ANSWER
400: invalid grant
Configuration in Actions Console

Problem seemed to be caused by the redirect of / to /index.php without the POST values.
Fixed it by changing my URLs in the Actions Console to /index.php and now the linking works fine.

Related

Sending with method POST comes in as method GET with ZF3 Http Client

I'm trying to make a POST request with ZF3 Http Client but it comes in as a GET request all the time. I checked the manuals on the zend framework website but I can't find what I'm doing wrong. Probably it will be something small.
My simple script from the client side is:
$request = new Client();
$request->setUri('http://keuringapp.localhost/inspections/pdf/66');
$request->setMethod(Request::METHOD_POST);
$response = $request->send();
die($response->getBody());
on the server side I have this:
$test = $this->getRequest();
print_r($test);exit();
``
and it give met this result:
Zend\Http\PhpEnvironment\Request Object
(
[baseUrl:protected] =>
[basePath:protected] =>
[requestUri:protected] => /nl/inspections/pdf/66
[serverParams:protected] => Zend\Stdlib\Parameters Object
(
[storage:ArrayObject:private] => Array
(
[REDIRECT_APP_ENV] => development
[REDIRECT_STATUS] => 200
[APP_ENV] => development
[HTTP_HOST] => keuringapp.localhost
[HTTP_CONNECTION] => close
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Zend\Http\Client
[PATH] => /usr/bin:/bin:/usr/sbin:/sbin
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache
[SERVER_NAME] => keuringapp.localhost
[SERVER_ADDR] => ::1
[SERVER_PORT] => 80
[REMOTE_ADDR] => ::1
[DOCUMENT_ROOT] => /Applications/MAMP/htdocs/keuringapp/public
[SERVER_ADMIN] => you#example.com
[SCRIPT_FILENAME] => /Applications/MAMP/htdocs/keuringapp/public/index.php
[REMOTE_PORT] => 55447
[REDIRECT_URL] => /nl/inspections/pdf/66
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /nl/inspections/pdf/66
[SCRIPT_NAME] => /index.php
[PHP_SELF] => /index.php
[REQUEST_TIME_FLOAT] => 1562241261.33
[REQUEST_TIME] => 1562241261
[argv] => Array
(
)
[argc] => 0
)
)
This question can be closed. It was a problem due to a language setting in the url

facebook developer posting to facebook but not showing on page

I am trying to post an image to a facebook page from a PHP script on my server. Everything is authenticating my account with admin rights and I have the permissions of manage_pages, publish_pages and publish_actions.
The image is getting uploaded and I can go to my facebook page and click on Notifications and the post is there, but when I go to Page, Posts, or Images I don't see it. Also, when I look at it in the notification section it is showing it posted by me and as a visitor, it should be showing as posted by the Page. I do have this set as live in Facebook Developer as well.
Can anyone help?
When I run the script I am doing this call to facebook:
$response = $fb->post('/'.$agency_permissions['facebook_page'].'/photos', $data, $agency_permissions['facebook_token']);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
}
Facebook returns this information: (things labeled '{removed by me}' were removed by me, not returned that way)
Facebook\FacebookResponse Object(
[httpStatusCode:protected] => 200
[headers:protected] => Array
(
[Access-Control-Allow-Origin] => *
[Pragma] => no-cache
[Cache-Control] => private, no-cache, no-store, must-revalidate
[facebook-api-version] => v2.11
[Expires] => Sat, 01 Jan 2000 00:00:00 GMT
[x-fb-rev] => 3698059
[Content-Type] => application/json; charset=UTF-8
[x-fb-trace-id] => H3yiZBKJGQe
[Strict-Transport-Security] => max-age=15552000; preload
[Vary] => Accept-Encoding
[X-FB-Debug] => {removed by me}
[Date] => Tue, 06 Mar 2018 20:43:16 GMT
[Connection] => keep-alive
[Content-Length] => 70
)
[body:protected] => {"id":"1139098132893012","post_id":"335620470144697_1139098132893012"}
[decodedBody:protected] => Array
(
[id] => 1139098132893012
[post_id] => 335620470144697_1139098132893012
)
[request:protected] => Facebook\FacebookRequest Object
(
[app:protected] => Facebook\FacebookApp Object
(
[id:protected] => {removed by me}
[secret:protected] => {removed by me}
)
[accessToken:protected] => {removed by me}
[method:protected] => POST
[endpoint:protected] => /335620470144697/photos
[headers:protected] => Array
(
[Content-Type] => multipart/form-data; boundary=5a9efd619ebd5
)
[params:protected] => Array
(
[message] => test
)
[files:protected] => Array
(
[source] => Facebook\FileUpload\FacebookFile Object
(
[path:protected] => /home/virtual/my_domain/public_html/wp-content///DemoUnitsInternal/7801.jpg
[maxLength:Facebook\FileUpload\FacebookFile:private] => -1
[offset:Facebook\FileUpload\FacebookFile:private] => -1
[stream:protected] => Resource id #26
)
)
[eTag:protected] =>
[graphVersion:protected] => v2.11
)
[thrownException:protected] =>
)
You are using a User Token, that´s why it gets posted as user. Make sure to use a Page Token with manage_pages and publish_pages and it will be posted as Page.

Yii2 Facebook Login issue: Error Validating Client Secret

I'm trying to activate Login via Facebook on my website that is built using Yii2 framework, but the Login is always failing, although the facebook app is authorizing the facebook account used in the login.
The response is always this error:
Request failed with code: 400, message: Error validating client
secret.
Im using yii2's authclient:
return [
'class' => 'yii\authclient\Collection',
'clients' => [
'facebook' => [
'class' => 'yii\authclient\clients\Facebook',
'authUrl' => 'facebook.com/dialog/oauth',
//Prod
'clientId' => 'appidhere',
'clientSecret' => 'appsecrethere',
'scope' => 'email, user_friends, public_profile',
.....
The app id and app secret are correct, and the fb app settings are correct as well.
Here's what the request looks like:
yii\httpclient\Request Object ( [_url:yii\httpclient\Request:private]
=> graph.facebook.com/oauth/access_token [_fullUrl:yii\httpclient\Request:private] =>
[_method:yii\httpclient\Request:private] => POST
[_options:yii\httpclient\Request:private] => Array ( [userAgent] => My
Application OAuth 2.0 Client [timeout] => 30 [sslVerifyPeer] => )
[isPrepared:yii\httpclient\Request:private] => [client] =>
yii\httpclient\Client Object ( [baseUrl] => graph.facebook.com
[formatters] => Array ( ) [parsers] => Array ( ) [requestConfig] =>
Array ( ) [responseConfig] => Array ( ) [contentLoggingMaxSize] =>
2000 [_transport:yii\httpclient\Client:private] =>
yii\httpclient\StreamTransport [_events:yii\base\Component:private] =>
Array ( ) [_behaviors:yii\base\Component:private] => )
[_headers:yii\httpclient\Message:private] =>
[_cookies:yii\httpclient\Message:private] =>
[_content:yii\httpclient\Message:private] =>
[_data:yii\httpclient\Message:private] => Array ( [client_id] =>
realappidhere [client_secret] => ​realappsecrethere [code] =>
AQAr0KRC0m4V4lqD8LVcQLNjn76xkZS4skQYAvWf6O_DDeEclaj1LMQm_HoyCoZZezqDn7p9YfJm3qENabU8MKvmH1ffNJotMzgLW2XTbSqQEXlkg_sx7V-ibXRFagpfXTIqCp9Kr54O88bNYGikoOr4TM1ogGjViwS-qKLbvpR_vWgE_FPy9ecpgy86QOITpGrlVJaPAun2bzGaFXmU70Z4Kw3kBWUBPseWc_7ILGymZP-CIbRIIm_YZ8p7t9Vo7jZmieMSd-CMYfG0sgJcBjOgQNvsa3xtHNhPVa5BJNNTy89zulSpTAf3XB6HB_8eql0
[grant_type] => authorization_code [redirect_uri] =>
example.com/site/auth?role=influencer&authclient=facebook )
[_format:yii\httpclient\Message:private] =>
[_events:yii\base\Component:private] => Array ( )
[_behaviors:yii\base\Component:private] => )
And the response is:
yii\httpclient\Response Object ( [client] => yii\httpclient\Client
Object ( [baseUrl] => graph.facebook.com [formatters] => Array
( [urlencoded] => yii\httpclient\UrlEncodedFormatter Object (
[encodingType] => 1 [charset] => ) ) [parsers] => Array ( )
[requestConfig] => Array ( ) [responseConfig] => Array ( )
[contentLoggingMaxSize] => 2000
[_transport:yii\httpclient\Client:private] =>
yii\httpclient\StreamTransport Object (
[_events:yii\base\Component:private] => Array ( )
[_behaviors:yii\base\Component:private] => )
[_events:yii\base\Component:private] => Array ( )
[_behaviors:yii\base\Component:private] => Array ( ) )
[_headers:yii\httpclient\Message:private] => Array ( [0] => HTTP/1.1
400 Bad Request [1] => WWW-Authenticate: OAuth "Facebook Platform"
"invalid_request" "Error validating client secret." [2] =>
Access-Control-Allow-Origin: * [3] => Pragma: no-cache [4] =>
Cache-Control: no-store [5] => facebook-api-version: v2.2 [6] =>
Expires: Sat, 01 Jan 2000 00:00:00 GMT [7] => Content-Type:
text/javascript; charset=UTF-8 [8] => x-fb-trace-id: Ek0PFIJ3B3N [9]
=> x-fb-rev: 2718923 [10] => Vary: Accept-Encoding [11] => X-FB-Debug: yaiIHJkwC4T3UZKrzXOJGJ2DmCTaDr8nIRB3jQnNeEiknx0Ph7i2IR5XmAbxpjM7cBhSEy44AcrglCYEdZEmeg==
[12] => Date: Sun, 04 Dec 2016 11:08:16 GMT [13] => Connection: close
[14] => Content-Length: 115 )
[_cookies:yii\httpclient\Message:private] =>
[_content:yii\httpclient\Message:private] =>
> {"error":{"message":"Error validating client
secret.","type":"OAuthException","code":1,"fbtrace_id":"Ek0PFIJ3B3N"}}
[_data:yii\httpclient\Message:private] =>
[_format:yii\httpclient\Message:private] =>
[_events:yii\base\Component:private] => Array ( )
[_behaviors:yii\base\Component:private] => )
So any idea what's happening in there?
Note: I removed the http and https from the facebook links in the quotes because stackoverflow wouldn't let me post more than 2 links.
Try using Yii2 EAuth extension. This is the best extention which provides social login over 14 diff platforms with the easiest way.
reference url:
https://github.com/Nodge/yii2-eauth
demo url : http://nodge.ru/yii-eauth/demo2/login

mixed up POST values in Perl script

I need to send POST values to server url, and I'm using this code:
$ogone_ua = new LWP::UserAgent;
$ogone_response = $ogone_ua->post("http://server.url/", {
'ACCEPTURL' => 'http://server.url2',
'AMOUNT' => '1000',
'CURRENCY' => 'USD',
'LANGUAGE' => 'en_US',
'ORDERID' => '20130105220939',
'PSPID' => 'vukasin',
'SHASIGN' => '6AEE128943C7C896A6449FF7C2CE702222995B7F'
} );
but server receives:
POST / HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Host: athlon.herrpan.com:2389
User-Agent: SSL-AirKiosk/1.0
Content-Length: 206
Content-Type: application/x-www-form-urlencoded
LANGUAGE=en_US&ACCEPTURL=http%3A%2F%2Fserver.url2&SHASIGN=6AEE128943C7C896A6449FF7C2CE702222995B7F&CURRENCY=USD&AMOUNT=1000&PSPID=vukasin&ORDERID=20130105220939
Why it is not in order? The bank API needs POST values to be sorted, just like in code.
Hashes don't have an inherent order, so the order is lost before ->post is even called. However, POST (to which ->post passes its args) also accepts an array reference.
->post("http://server.url/", [
ACCEPTURL => 'http://server.url2',
AMOUNT => '1000',
CURRENCY => 'USD',
LANGUAGE => 'en_US',
ORDERID => '20130105220939',
PSPID => 'vukasin',
SHASIGN => '6AEE128943C7C896A6449FF7C2CE702222995B7F',
]);

Paypal CreateRecurringPaymentsProfile 10002 error

I'm trying to create recurring payment profile using CreateRecurringPaymentsProfile method of Paypal API version 54.0 56.0 in Sandbox mode.
Unfortunately I'm getting 10002 error "You do not have permissions to make this API call".
I've rechecked API credentials for few times and it looks correct. Also other methods of API (ex. DoDirectPayment) works perfectly.
Does anybody faced such a problem? What a solution?
Thank you very much I need your help.
UPD:
The request is performed by Zend_Http_Client. Sending get array like:
array (
'USER' => 'user_1324103739_biz_api1.domain.com',
'PWD' => 'DCM6SLXFXLW99RRR',
'SIGNATURE' => 'signature',
'VERSION' => '56.0',
'METHOD' => 'CreateRecurringPaymentsProfile',
'TOKEN' => 'EC-12C13621A5208361W',
'IPADDRESS' => '127.0.0.1',
'USER_AGENT' => 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7',
'AMT' => 100,
'SUBJECT' => 'Silver plan monthly payment',
'CURRENCYCODE' => 'USD',
'COUNTRYCODE' => 'US',
'EMAIL' => 'user#email.com',
'PROFILESTARTDATE' => '2012-19-01CST3:48:2418',
'BILLINGPERIOD' => 'Month',
'BILLINGFREQUENCY' => 1)
The request example:
GET /nvp?USER=user_1324103739_biz_api1.domain.com&PWD=DCM6SLXFXLW99RRR&SIGNATURE=signature&VERSION=56.0&METHOD=CreateRecurringPaymentsProfile&TOKEN=EC-12C13621A5208361W&IPADDRESS=127.0.0.1&USER_AGENT=Mozilla%2F5.0+%28X11%3B+Linux+i686%29+AppleWebKit%2F535.7+%28KHTML%2C+like+Gecko%29+Chrome%2F16.0.912.63+Safari%2F535.7&AMT=100&SUBJECT=Silver+plan+monthly+payment&CURRENCYCODE=USD&COUNTRYCODE=US&EMAIL=user%40email.com&PROFILESTARTDATE=2012-19-01CST3%3A48%3A2418&BILLINGPERIOD=Month&BILLINGFREQUENCY=1 HTTP/1.1
Host: api-3t.sandbox.paypal.com
Connection: close
Accept-encoding: gzip, deflate
User-Agent: Zend_Http_Client
Response example:
TIMESTAMP=2011%2d12%2d19T09%3a55%3a14Z&CORRELATIONID=3fcaa599c0ad0&ACK=Failure&VERSION=56%2e0&BUILD=2230381&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Authentication%2fAuthorization%20Failed&L_LONGMESSAGE0=You%20do%20not%20have%20permissions%20to%20make%20this%20API%20call&L_SEVERITYCODE0=Error
SUBJECT is causing this. SUBJECT is meant for third-party API authorization where the value of SUBJECT is the email address / secure merchant ID of a third party which authorized you to call the API on their behalf, not as a descriptive text. For that you'll want to use 'DESC'.
I would also suggest removing:
IPADDRESS (not part of CreateRecurringPaymentsProfile API)
COUNTRYCODE (not part of CreateRecurringPaymentsProfile API)