What does {expires_at: 0} mean is debug_token response? - facebook-graph-api

Here is a response to my attempt to validate user's access_token.
{
"data": {
"app_id": 409277239141609,
"is_valid": true,
"application": "Les \u00e2mes vagabondes",
"user_id": 100003752867359,
"issued_at": 1353410808,
"expires_at": 0,
"scopes": ["create_note", "email", "manage_pages", "photo_upload", "publish_actions", "publish_stream", "share_item", "status_update", "user_birthday", "user_interests", "user_likes", "user_photos", "video_upload"]
}
}
It says that the access_token is valid, though does not give the expires_at timestamp. How do I get the expires_at then?

Little late to the party.. but I guess it means the access_token does not expire (eg. you're the developer of the Facebook App).

It means that the access token you have can no longer be used because of reasons such as the password change, etc. so that you should get a new access token.

Related

Facebook sender id is returned as [Filtered]

In our system, in some cases we are getting from the facebook API this
"sender": {
"id": "[Filtered]"
}
but not sure the reason.
Any thoughts?

Facebook Graph API get page_impressions

I've been using the graph api to get insights for our page. I log in, authorise and get a page access token. Recently, Facebook made it impossible to get any data without getting your app reviewed. I've managed to get my app reviewed with the following permissions:
manage_pages, email, read_insights, default:
These are found here: https://developers.facebook.com/docs/facebook-login/permissions/
This is my call:
https://graph.facebook.com/v3.0/me/insights/page_impressions_by_age_gender_unique
And this is the response:
{
"data": [
],
"paging": {
"previous":
"https://graph.facebook.com/v3.0/300196376675661/insights?access_token=xxx&pretty=0&metric=page_impressions_by_age_gender_unique&since=1532674800&until=1532847600",
"next": "https://graph.facebook.com/v3.0/300196376675661/insights?access_token=xxx&pretty=0&metric=page_impressions_by_age_gender_unique&since=1533020400&until=1533193200"
}
}
Are there additional permissions that I need to get in my app? Has anyone managed to get these insights?
Looking for these items:
[
("page_impressions_by_age_gender_unique", "day"),
("page_impressions", "day"), ("page_impressions_unique", "day"),
("page_impressions_paid", "day"),
("page_views_by_age_gender_logged_in_unique", "day")
]
This might help!
Your query should be like this =>
"<your_page_id>/insights?metric=page_impressions_by_age_gender_unique&accessToken=<your_page_access_token>"
Make sure to pass the Page Access Token, not user token.

How to set the password of a cognito user as the admin?

Via the cognito admin API how do I set a users password? When a user is created I can set a temporary password, I need to be able to do this to an existing user.
The newest version of the cognito api adds an action AdminSetUserPassword which has a request syntax like the following
{
"Password": "string",
"Permanent": boolean,
"Username": "string",
"UserPoolId": "string"
}
and will allow you to set a permanent or temporary password for a given user.
EDIT-2: The newest version of cognito API now supports AdminSetUserPassword.
You can't set a users password, the only thing you can do is use AdminResetUserPassword.
EDIT: You can call ForgotPassword too. But as the name suggests this is supposed to be called by a user, not an admin.
The latest of the Cognito API gives us AdminSetUserPassword which has a body of this kind
{
"Password": "string",
"Permanent": boolean,
"Username": "string",
"UserPoolId": "string"
}
using this you can set a password for a user considering yourself as an admin. You can get the UserPoolId from the Cognito user pools home page.
Headers goes as this :
X-Amz-Target: AWSCognitoIdentityProviderService.AdminSetUserPassword
Content-Type: application/x-amz-json-1.1
If you face any errors, kindly refer to this page for available headers: Making API Requests

How to publish a new post to facebook wall?

My app have been approved for publish_actions permission and I want to publish to user's wall behave my user. I tried to call the graph API like this:
https://graph.facebook.com/v2.7/me/feed?access_token=<token>&method=post&message=Hello
I read the facebook documents and It says A user access token with publish_actions permission can be used to publish new posts.
But actually I can't publish the message to user's wall. What I receive is:
{
"error": {
"message": "Invalid OAuth 2.0 Access Token",
"type": "FacebookApiException",
"code": 190,
"error_subcode": 1732004,
"is_transient": false,
"error_user_title": "Invalid Access Token",
"error_user_msg": "Invalid access token received.",
"fbtrace_id": "<trace code here>"
}
}
Do I make any mistake?
Update: Add screenshot of my token debugger information
This worked fine for me: https://graph.facebook.com/me/feed?access_token=xxx&method=post&message=test
Make sure the Access Token is valid and includes the publish_actions permission, you can test it here: https://developers.facebook.com/tools/debug/access_token/

Get user email server-side facebook

So I want to get users email address with my server-side code.(I can get it on client side) My apps scope is set to:
"scopes":["public_profile","email"]}
What I'm able to-do at the moment is verify that the users token is valid. But I'd like to request the email as well - just to make sure on server side, that i can log the person in to my website.
I use this address to verify the token belongs to my app:
https://graph.facebook.com/debug_token?input_token=%REPLACE%&access_token=%REPLACE%
How should my request look like if I'd like to next ask for users email on server side?
Appears another option (once/if you know the token belongs to your app) is:
https://graph.facebook.com/me&access_token=USER_ACCESS_TOKEN
by default it only returns id, if you want more, ex email:
https://graph.facebook.com/me?fields=email&access_token=USER_ACCESS_TOKEN
which returns both id and email.
One solution is:
https://graph.facebook.com/v2.1/<user_id>?access_token=<your_app_access_token>
will return:
{
"id": "<id>",
"email": "mihkel\u0040gmail.ee",
"first_name": "Mihkel",
"gender": "male",
"last_name": "Lastname",
"link": "https://www.facebook.com/app_scoped_user_id/<id>/",
"locale": "en_US",
"name": "Mihkel Lastname"
}
if you need only email you can set fields=email parameter :)
You need USER ACCESS TOKEN to get user mail Id,
you can the access token from the response of API call
response.authResponse.accessToken;