There is wonderful tutorial how to use OAuth2 api to be authenticated by github. But if I want to use same api for facebook. I tried following and end up with error. So how can use OAuth2 api for facebook?
fb.client.id=79756xxxxxxxx
fb.client.secret=205adxxxxx
fb.redirect.url= "https://graph.facebook.com/oauth/access_token?client_id=%s&redirect_uri=%s&client_secret=%s&code=%s"
// eventually url is filled as
https://graph.facebook.com/oauth/access_token?toeken&client_id=797565xxxx&redirect_uri=http://localhost:9000/_oauth-callback&client_secret=email&code=e3887ea3-3319-4462-a3b1-xxxxx
// get this error
{
"error": {
"message": "Invalid verification code format.",
"type": "OAuthException",
"code": 100
}
}
Update after updating the request url as
fb.redirect.url="https://graph.facebook.com/oauth/authorize?client_id=%s&redirect_uri=%s"
I managed to get facebook's login prompt. After submitting fb credential my redirect url is called as
http://localhost:9000/_oauth-callback/?code=AQD72MtTesmEIoQty3c0ZTC3a211egWR0pvVcLGhb6lB2T6TslG7r99IouP6KbE4oDYCl7n0_imyI0zxe-8Nb2CUDsRN5pEyQ_Pk6JRwy0JRy3T27kbDJ9DRcr11NrDdlZtNK3tOe6kfTdVQm52YXMTF7L9Kq3N6z0ZIBbVxsizvWZ00kVUL2YkSdnh5mpx4ofKaTgd0pHNhE9X33mBdzS7Evu_R0yW8XqgZFfvEPFE3f1e9qdrbrhwHaj1kfZyk6NigDBpnyZ5CgtzFTDpLHZVKQXCWDNzfqMwlxYuV2amTJUEgq77_HzxnDD3njvU4dJK0lrpVrkimqMeldCFEHzbV#_=_
I don't know how to use this code = XXX. Don't even know what does this code mean? How can ask user public profile info after my redirect url is called? Please let me
Related
I want to use Uber in my app by using its Rest API, and when I hit the same from Postman and i will get the same error every time
{
"message": "No authentication provided.",
"code": "unauthorized"
}
after entering the same request as given sample on the Uber Developers Site. you can also check the same here:
this is the link
And I am attaching here the pic of my request.
here is the image
In your Authorization header, replace server_token with Token.
So your example header has:
Authorization:server_token SERVER_TOKEN
replace that with:
Authorization: Token SERVER_TOKEN
I want to read the user's apprequest-id. I've already finish the function below:
get server token:
url = "https://graph.facebook.com/oauth/access_token?client_id=#{app_id}&client_secret=#{secret_key}&grant_type=client_credentials"
then, i built the function that sending user_token to server as {client_access_token}
So, I call this function to get AppRequest as json
url = "https://graph.facebook.com/v2.3/#{fb_id}/apprequests/?input_token=#{client_access_token}&access_token=#{server_access_token}"
And i got this error:
{
"error": {
"message": "(#15) Requires session when calling from a desktop app",
"type": "OAuthException",
"code": 15
}
}
At first, I think that there are something wrong with the URL calling or access token, but I've already test another graph api such as "/me/friends" and "/me/?fields=installed" with the same input_token and access_token. And, it works normally. Please help.
This problem has been solve by using {client_access_token} as access_token :)
url = "https://graph.facebook.com/v2.3/#{fb_id}/apprequests/?access_token=#{client_access_token}"
I went to https://developers.facebook.com/tools/explorer?method=GET, set up there ID of my Facebook page, set up there the correct permission for posting statuses on my FB timeline and generated access token.
Then I wanted to extend this short-live token on the long-term (60 days long valid token). So I did following - I put this URL to the browser:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID_OF_MY_FB_APP&client_secret=SECRET_ID_OF_MY_APP&grant_type=fb_exchange_token&fb_exchange_token=GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP
and in the browser I saw this error message:
{
"error": {
"message": "The access token does not belong to application APP_ID_OF_MY_FB_APP",
"type": "OAuthException",
"code": 1
}
}
Which is weird, because the APP_ID of my Facebook app is correct, I've tried to post on the wall of the Facebook page and it was working.
But when I try to get extended access token, I am getting the error above.
What's wrong with the access?
Thank you
This almost certainly means what the error says, which is that GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP is not actually from the app ID that you're using in the APP_ID_OF_MY_FB_APP parameter
Check the access token you're trying to extend in Facebook's Debug Tooland ensure it was actually generated for your app
Your AppID param is not the same to the AppID in developers.facebook.com
I try to get an access_token like this documentation : https://developers.facebook.com/docs/authentication/server-side/
but it does not work !
I have this error :
{
"error": {
"type": "OAuthException",
"message": "Error validating verification code."
}
}
In the documentation it says we can use :
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&
client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE
client_id is my app_id
client_secret is the App secret
redirect_uri is the url of the website (Site URL in app configuration) (I tried with / and without at the end)
So my url is :
https://graph.facebook.com/oauth/access_token?client_id=14588084****&redirect_uri=http%3A%2F%2Fwww.mywebsite.com&client_secret=693ce9538e1f14e0*********&code=AQCVmlM9peMiL8Pv3mdi7c3FifwGLQDECdtN0oGMW4I6cisebeawDdSHP_crQlhsZxHKDOFT6zOrqeaoiL2pkQSkqAvwoPZdw0o1uCoLpUVjchghgfhgfhEXb2XS3UBD7iEc8eZ_YLF0cbVWL5i58sj3Rsr9vVFtfYwfghghgfhgfTkwajGcRp9n-lWWcepxghgIwzMMYLv8e__iDoMDiSNg
It's been ages since I last coded a Facebook app. Not sure if this will help: Facebook access token and AJAX calls
I did quite a bit of homework before posting here but still could not find a solution for the following problem.
PROBLEM: when trying to access my facebook app's insights or subscriptions, it returns
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
I do everything according to the official documentation:
get app access_token by calling this api. It does return a token.
https:// graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
get insights/subscriptions by calling: https:// graph.facebook.com/APP_ID/subscriptions?access_token=TOKEN_FROM_STEP_1
but the last call returns the error message above.
Any ideas why?
After many trials and errors I found the solution.
Change facebook app type to 'Web' instead of 'Native'
Apparently facebook doesn't return subscriptions/insights for native apps