getting error 400 in device oauth flow - facebook

When making an http post:
https://graph.facebook.com/oauth/device?type=device_code&client_id=myclientid
I'm getting an http 400 error. Am I doing something wrong here? Is device_code supposed be something other than device_code? It doesn't look that way here:
https://developers.facebook.com/docs/authentication/devices/
I'm just starting to experment with browserless facebook auth.

Well, clicking https://graph.facebook.com/oauth/device?type=device_code&client_id=myclientid gets you a pretty clear error message:
{
"error": {
"message": "Unsupported type: 'device_code'. Supported types: web_server, user_agent, client_cred, username",
"type": "OAuthException",
"code": 1
}
}
The linked specification though says:
type
REQUIRED. The parameter value MUST be set to "device_code".
As Facebook is stating:
Both the specification and our implementation are constantly being refined, however, so some subtle differences should be expected.
that could be some temporary glitch between implementation and documentation.
Anyway, are you sure you already would have access to device authentication?
Please note that we are currently testing Device Authentication with a limited number of partners. It is not currently available for general use, and we are not accepting additional applications for access.

If you use the following URL(only the appId is changed) you will get result. It will return a code, id, verification URI etc. The fact is that the device flow api will work only for the above appId and which is provided by facebook. No other AppIds wont work. Everything will return an error like this
{
"error": {
"message": "Unsupported type: 'device_code'. Supported types: web_server, user_agent, client_cred, username",
"type": "OAuthException",
"code": 1
}
}

Related

Google Oauh2 Verification Invalid Argument

I'm trying to submit an application for a verification through the Google Console as it has opened from today.
I have verified the domain in question through Goofle Search Console, I have ensured that all the links are set(Policy, Terms of Usage etc), filled the form with information and explanation about the scopes rhat requires verification.
When I submit the form I get no response that it's submited but the response from Network in Developer tools I see it's 400 HTTP Status and I see the following error message:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
I have double checked my steps but still not able to resolve this, any information that you can provide would be great.
Adding Request:
https://clientauthconfig.clients6.google.com/v1/brands/ID/submitReview?alt=json&key=AIzaSysnipsnip0DjtiCwWBwQ1djDy741g
Above request is PUT, here is the body content
{"brandId":"ID","scopeRationale":"","additionalInfo":"","contactEmail":"contactmeialaddress#gmail.com","pendingScopes":["https://mail.google.com/","https://www.googleapis.com/auth/gmail.modify","https://www.googleapis.com/auth/gmail.compose","https://www.googleapis.com/auth/gmail.insert","https://www.googleapis.com/auth/gmail.readonly","https://www.googleapis.com/auth/contacts.readonly"],"category":[1,3,5],"scopeDetails":[{"apiGroup":1,"pendingScopes":["https://mail.google.com/","https://www.googleapis.com/auth/gmail.modify","https://www.googleapis.com/auth/gmail.compose","https://www.googleapis.com/auth/gmail.insert","https://www.googleapis.com/auth/gmail.readonly"],"scopeRationale":"Why we need access to this scope."},{"apiGroup":2,"pendingScopes":["https://www.googleapis.com/auth/contacts.readonly"],"scopeRationale":"Additional info why we need this."}]}

Validate Facebook work position targeting IDs

Our Facebook Ad system uses work position in its targeting spec as documented here: https://developers.facebook.com/docs/marketing-api/targeting-specs/v2.3#education_and_workplace
Sometimes Facebook deletes existing work positions and API requests to update the targeting spec fails:
{
"error":
{
"message": "Invalid parameter",
"type": "FacebookApiException",
"code": 100,
"error_subcode": 1487079,
"is_transient": false,
"error_user_title": "Invalid Targeting Spec",
"error_user_msg": "The specified targeting spec is not valid because: Job Titles with id 1542119359378854 is invalid."
}
}
The same happens with interest, but there is an API request to validate interests: https://developers.facebook.com/docs/marketing-api/targeting-search/v2.3#interest_validation
Is there something similar for work positions? (Probably undocumented?)
I could do requests to the /search/ API endpoint, but then I'd run into API request limits.
Unfortunately you are out of luck; there is no validation feature for work positions.
However, the example on the Facebook docs page you mentioned ([{'id':105763692790962, 'name':'Business Analyst'}]) seems to contain a working Facebook ID. Fetching e.g. https://graph.facebook.com/v2.2/105763692790962 will return the following output, so long as this profession exists:
{
"category": "Profession",
"name": "Business Analyst",
"id": "105763692790962"
}
This is of course not entirely what you are looking for, but if you want to limit the number of requests you make, you could implement your advertising app in such a way that it only tries to resolve professions by their ID once you run into trouble with your targeting spec. Getting back data for such a sanity check-request indicates that a work position is still valid. Should it not be valid any more, you can resort to using the /search endpoint to find a replacement.
You could also suggest that Facebook add this feature: https://www.facebook.com/help/suggestions

Open Graph user own created object issue

I'm following the documentation here:
https://developers.facebook.com/docs/opengraph/using-object-api/
Using the following:
/me/objects/<app-namespace>:<created-object>?privacy={"value":"SELF"}
&object={"image":"https://<image-url>"}&access_token=<user-token>
Testing with the Graph API tool i'm getting this error:
{
"error": {
"message": "(#200) Requires extended permission: publish_actions",
"type": "OAuthException",
"code": 200
}
}
Ok well that seems obvious until I debug the access token:
Valid True
Origin Mobile Web Faceweb
Scopes publish_actions, user_friends
Anyone else seen this or have an idea of how to fix it?
EDIT Ok so I had publish_actions in both User & Friends and Extended permissions. I removed the User & Friends permission and now I get this:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
Me no like unknown.
Ok so a couple things to note here that went wrong.
I picked an object type as an item thinking it would be <myapp>:item in the call. Well as it turns out the item is actually a product type so it is product.item a global type. What is handy is to actually click the get code link on the objects you create. Solution was to actually create my own app object type, which I thought I had.
In the Graph API make sure you actually use the application pull down in the top right to select the right app. I noticed some issues when it was set to the generic Graph API Explorer app.
Silly mistakes but cost me some time, hope it helps someone else.

facebook returns Unsupported get request on some apps?

I cannot understand the behavior of Facebook: this call working perfectly
https://graph.facebook.com/142809522573631?callback=jQuery18309434105455875397_1369031461008&_=1369031607843
but returning following error
({
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
});
on this call
https://graph.facebook.com/140402456132379?callback=jQuery18308404146176762879_1369033434327&_=1369034088376
How can I Fix this?
As you are getting error for Unsupported get request., then this means that the object is either not available or is having some restrictions due to which you can't perform a GET on the Object. As per your comments this was because the ID you were using corresponded to an application which was having Sandbox Mode enabled.
To solve your issue you should navigate to your app settings page and then select disabled for Sandbox Mode, and save the settings.

Authenticating Devices - Unsupported type

I want to use the device authentication as described in the documentation ( http://developers.facebook.com/docs/authentication/devices/ ) but I can't use it to authenticate with my facebook app, the return is always:
{
"error": {
"message": "Unsupported type: 'device_code'. Supported types: web_server, user_agent, client_cred, username",
"type": "OAuthException"
}
}
This seems to a be a known problem for several months. I've found several people with the same problem but it seems that they gave up or didn't bother to post the solution (example: http://forum.developers.facebook.net/viewtopic.php?id=91645#p322091 )
Can anyone use "https://graph.facebook.com/oauth/device?type=device_code&client_id=150792241632891" with their own applicationID?
I had another answer here but it seems that device auth for Facebook is behind a whitelist, i'm not sure how to apply - the docs probably shouldn't be publicly visible if the functionality isn't though, i'll try to see why that is