Facebook - "Cannot query users by their username" solution - android

I am developing an android app. I was using a HttpURLConnection to get profile pictures of facebook users. The URL looks like this:
http://graph.facebook.com/?ids=username1,username2,username3&fields=picture&type=square
But now, since v2.2 doesn't let me to get profile pictures of users who are not using my facebook app, it throws an error:
{ "error": {
"message": "(#803) Cannot query users by their username (username1)",
"type": "OAuthException",
"code": 803 } }
I am not interested in using "Facebook SDK for Android". Let's say I use a pop-up webview to authorize my facebook app. What url would let me do the same thing? Is there a simple solution like this:
graph.facebook.com/?app=APP-ID&ids=username1,username2&fields=picture

Since v2.0 of the API, you are not supposed to use usernames at all - and that´s why you can´t query users by their username anymore. The only way to get access to data of a user is by authorizing that user and using the /me endpoint.
Main rule: Forget about users who did not authorize your App, you are not supposed to get any data of those for privacy reason.

Related

Firebase - Getting profile photo url from auth having Facebook provider after Graph 8.0 update

I am currently using Facebook login for firebase auth for my android app and retriving user's photourl using
firebaseAuth.getCurrentUser().getPhotoUrl()
This gives me the photo url from the user's facebook profile.
Recently I have received mail from Facebook stating -
"Facebook will now require client or app access tokens to access a user’s profile picture when querying against user IDs. Beginning on October 24, 2020, queries for profile pictures made against user IDs without an access token will return a generic silhouette rather than a profile picture."
More on it on this link https://developers.facebook.com/blog/post/2020/08/04/Introducing-graph-v8-marketing-api-v8
My question -
Does the request firebaseAuth.getCurrentUser().getPhotoUrl() use access tokens to access url from facebook and will it function the same after the release of Graph API 8.0 on 24th Oct?
Or will I have to make a different query request to fetch the User's photo url for facebook provider?
Unfortunately, you'll have to add the access token to the photo url by yourself as Firebase does not and will not support it (as they don't have access to it - you can read more about it here).
You'll have to do something along the lines of:
firebaseAuth.getCurrentUser().getPhotoUrl() + "?access_token=<facebook_access_token>"
To be able to get the access token of facebook, after being logged-in with Firebase, you can use:
AccessToken.getCurrentAccessToken()
Complementing the answer of Marek Fort, with Kotlin you can get the picture doing something like that:
"${firebaseAuth.getCurrentUser().getPhotoUrl()}?access_token=${AccessToken.getCurrentAccessToken()}"
In kotlin it looks like:
"${firebaseAuth.currentUser?.photoUrl}?access_token=${AccessToken.getCurrentAccessToken()?.token}"

Deezer Rest API - Add Track to Playlist doesn't work?

I have an Android application integrated with the deezer rest API, and I need to add a track to a playlist.
My application already has Oauth login flow, when I execute the following request:
http://api.deezer.com/user/me?access_token=AJSDH44H5R7SS7SDHDUHFSUDUSUSASDA766
Works fine!
Playlist actions, I trying send this request as:
POST
http://api.deezer.com/playlist/777006545/tracks?access_token=AJSDH44H5R7SS7SDHDUHFSUDUSUSASDA766&songs=2312333,12312
GET
http://api.deezer.com/playlist/777006545/tracks?access_token=AJSDH44H5R7SS7SDHDUHFSUDUSUSASDA766&songs=2312333,12312&request_method=post
Callback error:
{
"error": {
"type": "OAuthException",
"message": "An active access token must be used to query information about the current user",
"code": 200
}
}
But the token works for other requests. What's the right way to do this, anyone know?
Have you checked this page?
https://developers.deezer.com/api/playlist#actions ?
It seems you already have found this one:
https://developers.deezer.com/api/actions-post
Here is what I would test:
POST only.
Check that your access token has the manage_library permission.
Check that the owner of the playlist is the same that the user of the access_token.
It worked for me with:
http://api.deezer.com/playlist/<playlist_id>/tracks?access_token=<access_token>&request_method=post&songs=<track_id>

Cannot get facebook video details using Graph API

I'm trying to get video information (source URL, preview URL, title, description) using Facebook Graph API on Android. Everything work fine for friend's videos and some random public videos found on Facebook.
However, it doesn't work for videos uploaded using testing user accounts. These users are not in my friends list.
The HTTP query is:
GET graph.facebook.com/v2.3/{video-id}
The API returns:
{
"error":
{
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
This happens both when using Facebook SDK for Android and Graph API Explorer (https://developers.facebook.com/tools/explorer).
This doesn't happen if I use APP Token instead of user access token.
If I use video owner's access token I can see video details but then requests fail for my own videos.
Every tested video is "public". I can watch these videos on Facebook without any problem.
Edit: following permissions are requested: "public_profile", "publish_actions", "user_videos", "user_birthday", "user_friends", "email", "user_location"
What am I doing wrong?
Have a look at
https://developers.facebook.com/docs/graph-api/reference/video#Reading
It states:
You must use a valid Page Access Token or User Access Token for any video with public privacy settings.
For videos uploaded by someone, and any videos in which they have been tagged you need a user access token for that person with user_videos permission.

Stuck on scrumptious tutorial, how to get an "active access token"?

The title pretty much sums it up, i am trying to test my Open Graph Actions in the Graph API Explorer but when i POST to /me/mynamespace:myaction, i get this error (Using the access token the Graph API Explorer generated for me, i asked for publish_actions only)
{
"error": {
"message": "(#15) This method must be called with an app access_token.",
"type": "OAuthException",
"code": 15
}
}
Ive done my homework and searched about it, to find a proper access-token to solve this problem goes by the APPID|APP_SECRET format but using that i get
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
Any ideas on how to solve this?
To give out more context the graph actions were created for an android facebook app.
You can't post to /me without a user access token from a user who's logged into your app, 'me' is a placeholder for 'current user'.
It sounds like two things have happened here:
You've configured the Open Graph action to require the App Access Token to post (which is a configuration option on the action
When you came across that error, you tried to use the App Access Token but didnt' change /me/mynamespace:myaction to /<USER ID>/mynamespace:myaction
Some notes:
Never put the app access token into your client code; it can be used to modify app settings. If you really need actions to only be postable via the app access token, you'll need to implement a server-side component to your app which makes the requests with the app access token
You probably need to change the open graph action settings for your action so it can be posted with a user access token
Your method of sending APP_ID|SECRET as an app access token is wrong. To get an app access token, you need to request it via this endpoint:
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
See here for more details

OAuth exception with invalid application id

Actually we created an app inside facebook and using the app id provided, the android application was able to post messages.
Recently we changed the facebook username and primary email address.
After this, our app stopped working on the facebook login. It doesnt event show us the facebook login screen in the webview.
We are getting the following exception
{
"error": {
"message": "Error validating application. Invalid application ID.",
"type": "OAuthException",
"code": 101
}
}
Will be happy is someone helps us out in this.
Thanks in advance.
Your app's code references an app ID, which is needed for the app to work with Facebook's API - If you cannot access that app ID via the API (a GET request to graph.facebook.com/<app ID here> will return an 'Unsupported GET request' error for an inaccessible app) it means that it's either in sandbox mode, and you can fix this from the app settings, or it's been deleted.
If the latter you'll need to create a new app and update your Android code to use that new App's app ID instead

Categories

Resources