I am creating a html page were am trying to get the recent updates about the company from following REST call :
http://api.linkedin.com/v1/companies/1441/updates?oauth2_access_token={access_token}
I am getting reply as invalid access token , I have created a new application on linkedin developer network obtained the accesstoken and i am supplying the same access token in the REST call to get company updates .
Can i please know how do i get recent company updates from linkedin using OAuth and bind the output data to some placeholder on html page.
The 'OAuth User Token' of the applicaiton in the LinkedIn Developer site is NOT the oauth2token. To get the oauth2token you have to authenticate (as a user) following this guide: https://developer.linkedin.com/documents/authentication
Good luck! :)
Related
I am trying to get a simple JSON package from putting the URL of my Google spreadsheet so I can use it on my webpage; I am using my Google Cloud Console API as it is said on the documentation of the v4 Google API format, but I still get the error of "Unauthorized API"
Documentation: https://developers.google.com/sheets/api/guides/migration#v4-api
I am using this URL:
https://sheets.googleapis.com/v4/spreadsheets/SHEET_ID/values/Sheet1?key=API_KEY
My google sheet is set as published on the web. And also I am the creator of the google sheet.
What could I be missing? I am new to API's!
First Edit:
Answering the comment of ABDULLOKH MUKHAMMADJONOV
Here is the code I am using to make a GET request to the google sheet, you can see the Sheet ID is there, and also the API of the google cloud platform.
fetch("https://sheets.googleapis.com/v4/spreadsheets/1S652uS2FLVoZ1m3apb6R4H783v6GkV58HbQ6Idec5aY/values/Sheet1?key=AIzaSyCpFZ7mcqMNc6Q_bP6h1kCEfAi6c_fd8AM", {"method": "get"})
.then( (httpResponse) => {
if (httpResponse.ok) {
console.log(httpResponse.json());
return httpResponse.json();
} else {
return Promise.reject("Fetch did not succeed");
}
} )
.then(json => console.log(json.someKey))
.catch(err => console.log(err));
This code is from the Wix code editor.
The caller doesnt not have permissions
Means that the user you are authenticated as does not have permission to do what it is you are trying to do.
The method
https://sheets.googleapis.com/v4/spreadsheets/SHEET_ID/values/Sheet1?key=API_KEY
I believe is this method spreadsheets.values/get if you check the documentation you will notice that it requires authorization with one of these scopes
You appear to only be sending an api key. You need to be authorized to access that sheet. You cant access it with an API key that only grants access to public data.
Ok, so I investigated about the OAuth 2.0 authentication and authorization for using Google Sheet's REST API. I added one of the needed scopes.
But I am stuck at the point on how to do the authorization process...
I am looking at this google documentation - How to use Google OAuth 2.0 authorization
But I haven't been able to get to the answer I seek. I am stuck at the part where it says "When your application needs access to user data, it asks Google for a particular scope of access." I do now know how to code this request or to do this request through the Insomnia software.
I am trying to do the GET request with a wix testing website, and also with Insomnia, but I haven't been able to achieve it.
These are the images from Insomnia, which tell me "Invalid authorization URL"
Insomnia's OAuth 2.0 authentication parameters
Insomnia's API Query parameter
I am trying to implement Facebook login SPA. I am using the JavaScript SDK for the login. Fb authorized the user and token is received. Token is send to the web API. When API try to fetch the data from the token only Facebook id and name return from the Facebook graph api. Even though I have set the scope for the different data in java script sdk. If i fetch the data using javascript sdk. In that case i am getting the complete data whatever in the scope.
I think your asking "why am I not getting all the data I requested?". If so the most common reason is because permissions aren't set. For instance if the user grants permission to "public_profile" then Facebook will authorize your app to obtain every field that that the "public_profile" permission permits, in this case the following:
id, name, first_name, last_name, age_range, link, gender, locale, picture, timezone, updated_time, verified
obtained via
FB.api('/me',
'GET',
{"fields":"id,name"}, //any of the other fields here
function(response) {
// Insert your code here
} );
however if added 'email' in as a field then the Facebook would return everything except the 'email' because there a permission specifically for granting access to the users email called email. You can see what permissions enable what data returns at https://developers.facebook.com/docs/facebook-login/permissions
and you can test it at https://developers.facebook.com/tools/explorer. I hope that's what you where trying to say in your question. Cheers!
This is driving me totally crazy. I've set up an FB app and retrieved an access token by visiting: https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET.
Now I want to grab a (publicly available) feed from this URL: https://graph.facebook.com/PAGE_OR_USER_ID/feed?access_token=ACCESS_TOKEN
It works fine when I try it with my own user ID or even when I try another random page but it DOESN'T work when I enter the PAGE_ID I need it to work with.
Here are some examples:
This works fine (a friend of mine's Facebook page):
https://graph.facebook.com/tatchit/feed?access_token=213451182120494|JgAwuCE74lh51t1pKMuRM2mz3GU&limit=10&offset=0
This also works fine (my own Facebook ID):
https://graph.facebook.com/al.dev.7/feed?access_token=213451182120494|JgAwuCE74lh51t1pKMuRM2mz3GU&limit=10&offset=0
This doesn't work (the client's Facebook page):
https://graph.facebook.com/142616539131188/feed?access_token=213451182120494|JgAwuCE74lh51t1pKMuRM2mz3GU&limit=10&offset=0
I don't get any errors but the result is empty.
If I try the Graph API Explorer it also works fine:
https://developers.facebook.com/tools/explorer/?method=GET&path=142616539131188%2Ffeed
But not if I enter my own access token. From what I understand the access tokens you get in the API Explorer are temporary so I don't want to use that.
How can this be?
Also. I've struggled to understand this whole access-token, client-id, app-id-business for ages now - is there a good tutorial where all this stuff is explained? I've never had this work without problems ever.
Thank you
You should be using user access token for all the above queries. App Access token is used when you want to do something like check the app insights so and so.
When the pages has age restrictions or something so, app token wont be able to get through, but since the user is already a member of the page, you can use the user access token to get the data.
Add : Quoting from the documentation,
Note that the **app access token** is for publishing purposes permitted by the publish_actions and publish_stream permissions. You will be **unable to retrieve information** about the status update post with the given ID using the app access token. Instead, you should use a **user access token** for such purposes.
Other Capabilities of an App Access Token
There is a limited set of information that can be retrieved from Facebook using an App Access Token.
Basic Profile Info of a User (ID, Name, Username, Gender)
A User’s Friends and their IDs
Permissions granted by the User to your App
Read : https://developers.facebook.com/docs/opengraph/using-app-tokens/
So you should be querying with the user_access token to access all the informations that you are looking for, not with an app access_token.
You are using an App Access token instead of a User Access token. Some of the pages you are viewing may have a country or age restriction set, so using an app token will not work.
See: http://developers.facebook.com/docs/concepts/login/access-tokens-and-types/
Is it possible to get the friends_online_presence with the Facebook Graph-Api?
When I request this url
https://graph.facebook.com/me?fields=id,inbox,friends_online_presence&access_token=XXXXXXXX
I get the error "message": "Unknown fields: friends_online_presence" Facebook-Documentation
friends_online_presence is the name of the permission needed to access the online presence, but the actual method to retrieve it is different. In FQL this should work:
select online_presence from user where uid in (select uid2 FROM friend WHERE uid1 = me())
Note that there's an open bug report about most users' statuses not being available; I"m unsure as to the status of that bug: https://developers.facebook.com/bugs/129383637170749
If you directly integrate with Facebook's XMPP servers (https://developers.facebook.com/docs/chat/) that might be more useful for your use-case depending on what you're trying to do
You can query the API with FQL (Facebook Query Language).
See this thread - Facebook API real-time friends' online presence update
Im trying to use javascript to determine if a user is a fan of a page that i've created on my account.
I found the facebook graph api which looks like just what i want. However it appears for some functionality i need an access token.
Here it says I can just http get my /user_id/accounts page with the manage_pages permission and it will list the access token for each page.
But when i submit https://graph.facebook.com/myuserid/accounts&scope=manage_pages i get "OAuthException : Access token is required to request this resource."
I also tried from this answer, but then i get "An error occurred, please try later".
Any suggestions most welcome.
You will need an access token to retrieve any information that is not public on facebook.
You can read up on this page about authenticating a user. Once your user is authenticated you can retrieve the access token and use it in your future requests (for that user)..
eg:
https://graph.facebook.com/{YOUR_USER_ID}/accounts&access_token={YOUR_ACCESS_TOKEN}