Share articles on linkedin not working with new v2 Api's - ios

We have an app where we are using social media share with Linkedin, earlier the app was using v1 Api and post share was working fine, but now all of the sudden it has stopped working. I checked on google seems like v1 Apis are now deprecated, so I tried using v2 api's. But now I am getting below error-:
Domain=com.alamofire.error.serialization.response Code=-1011 "Request
failed: forbidden (403)" UserInfo={NSLocalizedDescription=Request
failed: forbidden (403)
Below is the code where I am passing access permissions and all other parameters for getting access token.
- (LIALinkedInHttpClient *)client {
UIViewController *top = [UIApplication sharedApplication].keyWindow.rootViewController;
// [top presentViewController:secondView animated:YES completion: nil];
LIALinkedInApplication *application = [LIALinkedInApplication applicationWithRedirectURL:#"https://com.xxxxxx.linkedin.oauth/oauth"
clientId:#"xxxxxxxxx"
clientSecret:#"xxxxxxxx"
state:#"xxxxxxxxx"
grantedAccess:#[#"w_member_social"]];
return [LIALinkedInHttpClient clientForApplication:application presentingViewController:top.presentedViewController]; //[LIALinkedInHttpClient clientForApplication:application];
}
v2 URL - : https://www.linkedin.com/oauth/v2/shared?/accessToken, here accessToken is the valid token value which is appended to the URL, when I check the value in console.
I am not getting how to make a valid request with v2 Api's, or if there are more parameters that we need to pass for new Api's, can anyone help me on this? Thanks in advance.
Kindly let me know if any other information is required.

According to LinkedIn Share API v2.0, your HTTP call should be looked like this:
POST https://api.linkedin.com/v2/shares
json:
{
"content": {
"contentEntities": [
{
"entityLocation": "https://www.example.com/content.html",
"thumbnails": [
{
"resolvedUrl": "https://www.example.com/image.jpg"
}
]
}
],
"title": "Test Share with Content"
},
"distribution": {
"linkedInDistributionTarget": {}
},
"owner": "urn:li:person:324_kGGaLE",
"subject": "Test Share Subject",
"text": {
"text": "Test Share!"
}
}

Related

Microsoft Graph API Create OnlineMeetings Error - Expected not null\r\nParameter name: meeting

My issue looks very similar to:
Microsoft Graph API OnlineMeetings Error - Expected not null\r\nParameter name: meeting
However the posted solution is not working for me. Presently I'm using postman and posting to:
https://graph.microsoft.com/v1.0/users/MyAzureUserObjectID/onlineMeetings
Currently this is my body:
{
"startDateTime":"2021-07-12T14:30:34.2444915-07:00",
"endDateTime":"2021-07-12T15:00:34.2464912-07:00",
"subject":"Application Token Meeting 2",
"participants": {
"organizer": {
"identity": {
"user": {
"id": "MyAzureUserObjectIDHere"
}
}
}
}
}
I've tried a few variations of participants and fields but always get:
{
"error": {
"code": "InvalidArgument",
"message": "Expected not null\r\nParameter name: meeting",
"innerError": {
"request-id": "3ea5c99c-a346-4c3a-8f38-dcdc9fb4d864",
"date": "2021-03-23T19:59:28",
"client-request-id": "3ea5c99c-a346-4c3a-8f38-dcdc9fb4d864"
}
}
}
returned. Has anyone had a similar issue/have any idea what I might do get this to work?
Thanks.
I had the same problem which also wasn't resolved by simply adding the participant.
The thing that fixed it for me was using the correct content type in the header. As I had started with the starter project from Microsoft Teams, I had copied and pasted some of their example code for the meeting request. You need to use 'Content-type': 'application/json'.
Also for the body, I had to use JSON.stringify around it to get it to function correctly.

How do i get EC_v1 version of Apple Pay PaymentToken

I'm trying to Integrate Apple Pay in my application. Following the online docs and some SO help, I've managed to show the Apple Pay payment dialog and all the call backs are configured.
the response returned from the Apple Pay is something like this
{
"version": "RSA_v1",
"signature": "somestring",
"data": "DP...A=",
"header": {
"wrappedKey": "MF...5g==",
"publicKeyHash": "kd...l4=",
"transactionId": "a5...3e"
}
}
But my requirement is to get ephemeralPublicKey under header object. According to Apple Pay Payment Token Format Reference
the returned object is correct as its RSA_v1 version which will not have ephemeralPublicKey but wrappedKey. Now my question is how do i get EC_v1 version of the returned token object.
May be I'm missing something here in the docs but please someone point me to the right direction. Any help is appreciated.
Here is the way to get this returned response from the Apple Pay Gateway server. You can't see this response in the console directly. You can see this response only if you will log it on the server by using an ajax request. See mine below sample URL and my source code.
Full Documentation for beginners
https://gist.github.com/jagdeepsingh/c538e21f3839f65732a5932e35809d60
session.onpaymentauthorized = (event) => {
$("#paymentMethodVal").val("apple-pay");
$form = $("#reservation-form");
console.log($form.serialize());
callRequest({
url: '/reserve/init-apple-pay',
method: 'POST',
data: {
token: event.payment.token,
reservationData: $form.serialize()
},
beforeRequest: function(e) {},
afterRequest: function(response) {
response = JSON.parse(response);
if(response.status){
toastr.success(response.message);
session.completePayment(ApplePaySession.STATUS_SUCCESS);
}else{
toastr.error(response.message.split(/\r\n|\r|\n/g).join('<br/>'));
session.completePayment(ApplePaySession.STATUS_FAILURE);
}
}
});
};
token: event.payment.token, line is your answer this will send data directly to server and you can log data over there.
{
"version": "RSA_v1",
"signature": "somestring",
"data": "DP...A=",
"header": {
"wrappedKey": "MF...5g==",
"publicKeyHash": "kd...l4=",
"transactionId": "a5...3e"
}
}

How to make a localPost with media using GMB API?

I am able to make localPost using GMB api.
However, when I add media, it gives me an error.
The error is as following.
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [
{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
My source code is as following.
Also, I installed google/apiclient from github and GMB library from here
$mediaItem = new \Google_Service_MyBusiness_MediaItem();
$mediaItem->setSourceUrl("https://example.com/test");
$mediaItem->setMediaFormat('PHOTO');
$media[] = $mediaItem;
$post = new \Google_Service_MyBusiness_LocalPost();
$post->setSummary($summary);
$post->setCallToAction($callToAction);
$post->setMedia($media);
$obj = new \Google_Service_MyBusiness($client);
$obj->accounts_locations_localPosts->create($accountLocation,$post);
If I comment out
"$post->setMedia($media);", I can make localPost.
Do you have a suggestion for this?
Best regards,
I solved myself.
Before:
$mediaItem->setSourceUrl("https://example.com/test");
After:
$mediaItem->setSourceUrl("https://example.com/test.jpg");
The reason why I could not make localPost is that the image extension should be image extension.
Google API dose not allow us to post the image that has not extension.
Cheers.

How to send push notification from Rest API

I have created my App in Firebase and configured for cloud messaging.
When I am sending the notification from Firebase Console, device gets the notification but if I try to send via Rest API (Using PostMan).
Then notification not coming to device but the response is showing as Success.
Here is my PostMan request
URI - https://fcm.googleapis.com/fcm/send
Header: Content-Type:application/json Authorization:key=MY_SERVER_KEY
Body: { "data": { "title": "Firebase", "detail": "I am firebase" },
"to" : "MY FCM TOKEN HERE" }
Response : {
"multicast_id": 7834540847388366233,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1532422122326299%ebf5f25ef9fd7ecd"
}
] }
I have searched and it seems the way mentioned in documentation is same as I am following
Can anyone let me know why it is not working?
Thanks
I am posting here so as to guide others. As per the guidance of #rv7284, We need to send the data in notification key rather any other key.
So While requesting the body should look like this, Other request parameter like header and all will be same as mentioned in the question.
{ "notification": {
"title": "Firebase",
"detail": "I am firebase"
},
"to" : "YOUR FCM TOKEN"
}

Google+ api moments insert unauthorized message

I'm trying to insert moments, using access_token, that i generated here https://developers.google.com/oauthplayground/ and receive "Unauthorized" message. What i do wrong?
My request is:
{
"target": {
"url": "http://example.com"
},
"type": "http://schemas.google.com/AddActivity"
}
I send this data on
www.googleapis.com/plus/v1/people/me/moments/vault?access_token=######, where ###### - my access token.
The response is:
{
"error":{
"errors":[
{
"domain":"global",
"reason":"unauthorized",
"message":"Unauthorized"
}
],
"code":401,
"message":"Unauthorized"
}
}
i had the same problem, i solved it by adding "request_visible_actions" and also make sure you have the login scope set on your request i.e "https://www.googleapis.com/auth/plus.login"

Resources