Bitbucket Event Payload Not As Expected - php

I am interested in getting bitbucket event payloads as they occur (e.g repo push, pull request created) in my application. I have all the necessary stuff ready (app descriptor, webhooks etc.)
I am able to get the event payload in event controller/handler when bitbucket sends event payload on that. But the payload is not as expected. See event payload docs for what should I be getting.
But, what I actually get is something like this
Array(
[ciphertext] => someciphertext
[encrypted_key] => yJGtBQD3x1oHxaB
[header] => Array
(
[alg] => PBES2-HS512+A256KW
[kid] => ari:cloud:bitbucket::app/{259e10da-4427-4b0}/test-app
[p2c] => 8192
[p2s] => TM6HLQpGaYg
)
[iv] => MtspXopJ4A
[protected] => eyJlbmEyIn0
[tag] => N4d5b4KsKhc
)
This seems like some encrypted data. Any pointers what it actually is and if it is encrypted how can I decrypt it.

Related

How to invoke my application on google home simulator without dialog flow integration?

I want to invoke my application from google home simulator but without integration of dialogflow is that possible? i provided fulfillment url in Actions Console but it does not invoke my app and shows me an error.
You cannot use standard Google Assistant features in the Simulator. If
you want to try them, use Google Assistant on your phone or other
compatible devices.
below is my php code.
sendMessage(array(
'expectUserResponse' => true,
'expectedInputs' =>
array (
0 =>
array (
'inputPrompt' =>
array (
'richInitialPrompt' =>
array (
'items' =>
array (
0 =>
array (
'simpleResponse' =>
array (
'textToSpeech' => 'Hi!',
),
),
),
),
),
'possibleIntents' =>
array (
0 =>
array (
'intent' => 'actions.intent.TEXT',
),
),
),
),
'conversationToken' => '{"data":{}}',
'userStorage' => '{"data":{}}',
));
You can use actions on google without any integrations with Dialogflow using the actionsSDK, but without Dialogflow you dont have a service which analyzes your users input and breaksdown intents and entities. So if you want to remove Dialogflow from your setup you will have to use a different service which takes the input from your user and analyzes it.
Using the actions SDK, you can provide a webhook URL using the gactions CLI and here you will have to write code which sends the input to the NLP and returns an intent. Then you can use that info to do the logic that you need to create a response for the user.
I personally haven't tried mocking the requests and tried to invoke my action with messages, but if you want a normal assistant, but without Dialogflow. That is how you can do it.

Amazon EC2 spot instance requests seem to be throttled

I can't get more than 2 spot instances into to be fulfilled at any given time.
Requests are for m3.large Windows instances.
Request bids are above the current price for all zones in us-east-1
Account Spot Request limitation is currently 40.
Account limit for m3.large instances is 20.
If I manually request 3 I receive a status of capacity-oversubscribed for the third, always. If I cancel one of the two that are fulfilled, the third is fulfilled.
If I request 3 through the API, 2 are fulfilled and I get a status of az-group-constraint. If I cancel one of the successful requests, the third is fulfilled.
This seems like I'm hitting some kind of limitation that I'm not aware of or some kind of throttling.
This is request array I'm sending over:
Array
(
[DryRun] => false
[SpotPrice] => 0.13
[InstanceCount] => 1
[Type] => one-time
[ValidUntil] => 1418087849 // about an hour from the original request
[LaunchGroup] => d4768b0ba115414a70d2fd8ffe3e6d67 // unique to each request
[AvailabilityZoneGroup] => us-east-1
[LaunchSpecification] => Array
(
[InstanceType] => m3.large
[ImageId] => ami-34222d5c
[KeyName] => thu
[Monitoring] => Array
(
[Enabled] => false
)
[SecurityGroupIds] => Array
(
[0] => sg-31273f54
)
)

how to get event details from google calendar

i succeeded in getting a push notification from google calendar into my system, when a new event is created in the calendar.
the push notification has no data in the POST body and the POST headers are these:
[Host] => xxxxxx.xxxx.com
[Content-Type] => application/json; charset=UTF-8
[Accept] => */*
[X-Goog-Channel-ID] => xxxxxxx-xxxxxxxx-8824-f0c2166878be
[X-Goog-Channel-Expiration] => Thu, 04 Dec 2014 04:27:13 GMT
[X-Goog-Resource-State] => exists
[X-Goog-Message-Number] => 11897215
[X-Goog-Resource-ID] => xxxxxxxxxx-xxxx-pSbC27qOUfg
[X-Goog-Resource-URI] => https://www.googleapis.com/calendar/v3/calendars/xxxxxxx#gmail.com/events?key=AIzaSyC_0nytiZWHfabrpWiExxxxxxxxxxx&alt=json
[Content-Length] => 0
[Connection] => Keep-alive
[Accept-Encoding] => gzip,deflate
[User-Agent] => APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)
where are the new event details that was created in the calendar?
how do i get them?
no information online and no information in google documentation (been searching for hours):
https://developers.google.com/google-apps/calendar/v3/push
where are the event details??
UPDATE:
i set a watch on my calendar using this code:
service = new Google_Service_Calendar($client);
$channel = new Google_Service_Calendar_Channel($client);
$uuid = gen_uuid();
$channel->setId($uuid);
$channel->setType('web_hook');
$channel->setExpiration('1919995862000');
global $sugar_config;
$address = $sugar_config['site_url'] . "/index.php?entryPoint=updateFromCal";
$channel->setAddress($address);
$watchEvent = $service->events->watch($bean->google_cal_id_c, $channel);
This is the channel details i send to google calendar api:
[address] => https://mydomainXXXX/index.php?entryPoint=updateFromCal
[expiration] => 1919995862000
[id] => xxxxxxxxxxxxxxx--4558-ac19-b82e0ca32206
[kind] =>
[params] =>
[payload] =>
[resourceId] =>
[resourceUri] =>
[token] =>
[type] => web_hook
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
i still get the same resource ID in the response, with every new event i create in the calendar! why can't i get the event ID of the event i just created? what did i do wrong? am i watching events or channels?
the reply i get is still the one mentioned above, its with the same resource id all the time.
The push does not contain any data. It only tells you that something changed in that resource. You will need to do a list request to find out what it was. Preferably this list request will be an incremental sync. Take a look into how to do synchronization here: https://developers.google.com/google-apps/calendar/v3/sync
You are missing the incremental sync. From the creators themselves slightly revised according to my tastes:
The first thing the app needs to do is get the new push functionality is to subscribe to a calendar of interest. When a calendar changes, Google will notify your app and the app does an API call to get the update.
As an example, let’s assume you have a calendar my_calendar#my-host.com. Your app is hosted on a server with my-host.com domain and push notifications should be delivered to an HTTPS web-hook https://my-host.com/notification
Every time my_calendar#my-host.com changes, the Google Calendar server will trigger a web-hook callback at https://my-host.com/notification. After receiving the callback the app needs to do an incremental sync.
To get the event details, you need to make a GET request, which should return the resource information as a JSON response. You can do so by passing in the Calendar ID and the Event ID (the eventId in this case should be your resource-ID, assuming that your notification was set to watch events).

Google Calendar Push Notification watch command in php

I am using the php watch commant:
$service = new Google_Service_Calendar($client);
$channel = new Google_Service_Calendar_Channel($client);
$channel->setId('20fdedbf0-a845-11e3-1515e2-0800200c9a6689111');
$channel->setType('web_hook');
$channel->setAddress('https://www.exampel.com/app/notification');
$watchEvent = $service->events->watch('primary', $channel);
This command works fine and I get the response:
Google_Service_Calendar_Channel Object ( [address] => [expiration] => 1401960485000 [id] => 20fdedbf0-a845-11e3-1515e2-0800200c9a6689111 [kind] => api#channel [params] => [payload] => [resourceId] => HZjSdbhwcd5KMKEA3ATA31LoR-w [resourceUri] => https://www.googleapis.com/calendar/v3/calendars/primary/events?key=AIzaSyBl_Y7Y4eQDve-0DjwzBEP7_qOLo-67ouY&alt=json [token] => [type] => [modelData:protected] => Array ( ) [processed:protected] => Array ( ) )
However; In my set up url I don't get any message when something changes in my calendar.
Am I missing something!?
I had a similar issue which was caused by authentication on my application.
Try sending a post request to https://www.exampel.com/app/notification and see if it is received. If not, double check your routing or authentication.
Also ensure that the endpoint is a valid https URL. Self-signed certificates are not allowed.
Source: https://developers.google.com/google-apps/calendar/v3/push
I have faced this issue today, so want to add some more details here.
Google only send the headers to your URL. so if you are waiting for getting some data (just like me) you won't get any (except some cases).
Check this Google Calendar API docs for Receiving Notifications
Understanding the notification message format
All notification messages include a set of HTTP headers that have X-Goog- prefixes. Some types of notifications can also include a message body.
Here are the headers I received in my webhook callback URL.
[Host] => mydomain.com
[X-Goog-Channel-ID] => 10ddfddt0-a995-10f4-1254e2-0000000a0a0609001
[X-Goog-Channel-Expiration] => Thu, 11 Jan 2018 10:04:04 GMT
[X-Goog-Resource-State] => exists
[X-Goog-Message-Number] => 2526579
[X-Goog-Resource-ID] => 9OG_a-ECJycPkpNR1ZrWSon5_i1
[X-Goog-Resource-URI] => https://www.googleapis.com/calendar/v3/calendars/primary/events?maxResults=250&alt=json
[Content-Length] => 0
[Connection] => keep-alive
[User-Agent] => APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)
[Accept-Encoding] => gzip,deflate,br
I also found some additional code sample here which you can use if you want to make the request to Google API without client library.
Hope this help someone.

OpenID check_authentication not working

Merged with OpenID check_authentication not working.
I'm trying to write my own provider in PHP (JanRain libraries are confusing as all hell, and even phpMyID doesn't document exactly what is happening). I've got authentication working, but when the relying party tries to do check_authentication, it says my server denied it.
This is debugging information I captured during a check_authentication request.
$_GET:
Array
(
[mode] => profile
[username] => jrhodes
[domain] => roket-enterprises.com
)
$_POST:
Array
(
[openid_assoc_handle] => {HMAC-SHA1}{4abdf2f1}{olw8ag==}
[openid_identity] => http://www.roket-enterprises.com/openaccount/openid:jrhodes
[openid_mode] => check_authentication
[openid_response_nonce] => 2009-09-26T10:54:41ZLg0kfQ
[openid_return_to] => http://www.wasab.dk/morten/2007/11/openid/?janrain_nonce=2009-09-26T10%3A54%3A37Z9rZCkP&openid1_claimed_id=http%3A%2F%2Fwww.roket-enterprises.com%2Fopenaccount%2Fopenid%3Ajrhodes
[openid_sig] => Xl94j3IJtfSEQ4oKfova68I8edc=
[openid_signed] => assoc_handle,identity,mode,response_nonce,return_to,signed,sreg.email,sreg.fullname,sreg.nickname
[openid_sreg_email] => jrhodes#roket-enterprises.com
[openid_sreg_fullname] => James Rhodes
[openid_sreg_nickname] => jrhodes
)
Using Specific Mode Endpoint Handler...
Answering check_authentication
Headers:
Content-Type: text/plain;
openid.mode: id_res;
openid_mode: id_res;
sreg.fullname: James Rhodes;
sreg.nickname: jrhodes;
sreg.email: jrhodes#roket-enterprises.com;
is_valid: true;
The GET and POST data is the data that my script is receiving. Everything after "Headers:" are the headers that my script is returning. According to the specifications, I can't see anything wrong with this.
I've been asking on #openid for the last 4 hours and haven't got a response (note to self: post on StackOverflow, then ask IRC). Can anyone help?

Categories