Facebook Graph-API Like a Page with Auth Token - facebook-graph-api

I read through the facebook refence-api-documentatons and the facebook permission-api very precise, but the following doesn't work:
curl -F "access_token=$access_token" https://graph.facebook.com/$APP_ID/likes
where $access_token is a token with the permissions: email,publish_stream,user_likes
I get the error:
"error":{"message":"(#3) Application does not have the capability to
make this API call.","type":"OAuthException"
What is wrong?
On the graph-api-refence-site is written:
You can comment on or like any object that has a /comments or /likes connection by posting to graph.facebook.com/OBJECT_ID/comments and graph.facebook.com/OBJECT_ID/likes, respectively:
curl -F 'access_token=...' http://graph.facebook.com/313449204401/likes

Related

Getting the OAuth Token from FedEx to use for Track API

I'm trying to get the OAuth Token to get auth access to some of the FedEx APIs ( like Track API for tracking shipments ), but I get a
401 (NOT.AUTHORIZED.ERROR -> "The given client credentials were not valid. Please modify your request and try again") error.
(At the moment, I'm using Postman to try and test the APIs.)
Here is the url I'm using, found provided by FedEx:
https://apis-sandbox.fedex.com/oauth/token
I've followed ( to my understanding ) how the body and headers should be set:
Headers: Content-Type: application/x-www-form-urlencoded
Body: x-www-form-urlencoded (Postman option):
grant_type: client_crendentials
client_id: ***PROJECT_API_KEY
client_secret: ***PROJECT_SECRET KEY
After sending, I only get the error message above. I checked / doubled-checked my API keys, but I can't seem to get it to go through.
Any ideas?
postman settings:
POST - URL https://apis-sandbox.fedex.com/oauth/token
Headers - Content-Type: application/x-www-form-urlencoded
Body - x-www-form-urlencoded:
grant_type: client_credentials
client_id: *******
client_secret: *******
(information gotten from https://developer.fedex.com/api/en-us/catalog/authorization/v1/docs.html)
The sandbox API credentials are not immediately usable when creating a new account. It took >1 hour for me to get a registration complete email from FedEx after which the sandbox credentials became valid.

How to use Authorization in Postman collections?

I have URL for get user details (GET method) while running the URL its showing the response below.
{
"message": "Invalid Basic Auth credentials"
}
URL details below
http://localhost:4567/v1/candidates
they mentioned following for authorization
-H "Authorization: Basic *********************************"
How can I use this in Postman collection?
Go to postman Authorization Tab and select Basic Auth as type and type the required credentials (username and password)
Add the Basic xxxxxxxxx to the Authorization header in your call:

how to get google authorization code

Im using Google tutorial to get access token for my web application. but in the following steps:
Your web application redirects the user to Google Authorization page
User grants your web application access
Google redirects the user back to your web application and returns an authorization code
I dont know how to get this authorization code ? actually in my python code I dont know how to get "auth_code"
data = urllib.urlencode({
'code': auth_code,
'client_id': client_id,
'client_secret': client_secret,
'redirect_uri': redirect_uri,
'grant_type': 'authorization_code'
})
I found my solution :)
I should past this url in my browser and get the code
print '%s?client_id=%s&redirect_uri=%s&scope=%s&response_type=code' % \
('https://accounts.google.com/o/oauth2/auth',
clientID,
redirect_uri,
'https://www.googleapis.com/auth/fusiontables')

How to access WSO2 API Manager's Store API?

I was reading the WSO2 APIM documentation for their Store API. However I can't figure out how to get authenticated with this API.
From what I understand from this page, I need to get a special token via the /token API. But the example shows that they provide some sort of Authentication to get this token and I can't figure out which one it is.
So I guess my problem is:
- How to get an access token for the WSO API Manager's new Store API?
Here is how to get access(Reference).
1.Register your oauth application using dynamic client registration API
curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -d #payload.json http://localhost:9763/client-registration/v0.9/register
Sample payload:
{
"callbackUrl": "www.google.lk",
"clientName": "rest_api_store",
"tokenScope": "Production",
"owner": "admin",
"grantType": "password refresh_token",
"saasApp": true
}
Here it uses basic auth.You need to provide base 64 encoded username:password(eg: admin:admin) in the Authrization header.
Sample response.
{
"callBackURL": "www.google.lk",
"jsonString":
"{
"username":"admin",
"redirect_uris":"www.google.lk",
"tokenScope":[Ljava.lang.String;#3a73796a,
"client_name":"admin_rest_api_store",
"grant_types":"authorization_code password refresh_token iwa:ntlm
urn:ietf:params:oauth:grant-type:saml2-bearer client_credentialsimplicit"
}",
"clientName": null,
"clientId": "HfEl1jJPdg5tbtrxhAwybN05QGoa",
"clientSecret": "l6c0aoLcWR3fwezHhc7XoGOht5Aa"
}
2.Use the token API to get the oauth access token
curl -k -d "grant_type=password&username=admin&password=admin&scope=apim:subscribe" -H "Authorization: Basic SGZFbDFqSlBkZzV0YnRyeGhBd3liTjA1UUdvYTpsNmMwYW9MY1dSM2Z3ZXpIaGM3WG9HT2h0NUFh" https://127.0.0.1:8243/toke
Here basic auth parameter is base 64 encoded clientId:ClientSecret
Now you have an access token to call store APIs

Django-social-auth google oauth token usage

I'm using Django-socila-auth plugin. It uses google API for Oauth 1.0 Authentication. Question is have anybody used it with google python API (gdata). I mean how to apply auth session_token, stored in django-social-auth model to my api call.
Can you help me with code to get this token from model and apply to gdata.PhotoService() instance. For now it is like this:
#getting model instance from django-social-auth model
association = Association.objects.get(user=request.user)
google_session_token=association.handle
google_secret=association.secret
#token string from django-social-auth
#model Association field "handle" looks like:
#google_session_token = '.......XG84PjwytqJkvr8WQhDxm1w-JplWK5zPndSHB13f.........'
gd_client = gdata.photos.service.PhotosService()
gd_client.debug = 'true'
gd_client.auth_token = google_session_token
#image.image is a file field, but problem not in this.
#it tries to send file in debug text.
#It just recieves 403 unauthorised callback.
photo = gd_client.InsertPhotoSimple(
'/data/feed/api/user/default/albumid/default', 'New Photo',
'Uploaded using the API', image.image, content_type='image/jpeg')
I'm recieving error
403 Invalid token string.
I understand that it needs secret too but how to apply it to API for auth?(To receive authorization to post photos.). BTW I added Picassa feed URL, as an option string for social-auth to ask permissions, so token I have asks for Picassa feed permissions when authorizing with google.
BTW. Google tutorial I've used is: here
I understand it's Oauth 1.0 rather than AusSub, but question is:
how to authenticate with token and secret I have and post a photo with this permission?
Just to answer my own problem. I used wrong way to do it, because problem in 'gd_client' and AuthSub.
It must check token on server. And it can not do it on localhost. You need to look ahead to Oauth/Oauth2 for better debugging and so on... No matter that it is much complex than AuthSub