I'm using django-social-auth to authenticate users for facebook login for my website.
<a href="{% url socialauth_begin 'facebook' %}?redirect_uri={{SITE_URL}}complete/facebook/">
This correctly leads me to an auth dialog, but then when I click "Go To App" in the dialog I get this error from social auth:
Request Method: GET
Request URL: http://[site_url]/complete/facebook/?state=DHlD9efEDau286xRGn2HtVpZ9AbooD3y&code=AQCACZRE3WYGMyBSII1eD-H8Sl8yDUtL6VoZ4qJPKSQ_NDBAoE_6JE7-4Ef353utpAygCZVJMUKiLNs_evC-y2oezOKRsH_njtFZW4FwPE2XoaFm14sdbtUkj1QsqivY6DSpGpsmTNCCs3twYxx-6_C-e1OWEcnd4x6SoBg59LmCUsWhocu739h_ppdLRR_wPjY
Django Version: 1.3.1
Exception Type: AuthFailed
Exception Value:
Authentication failed: There was an error authenticating the app
Exception Location: /app/.heroku/src/social-auth/social_auth/backends/facebook.py in auth_complete, line 131Request Method: GET
Request URL: http://[site_url]/complete/facebook/?state=DHlD9efEDau286xRGn2HtVpZ9AbooD3y&code=AQCACZRE3WYGMyBSII1eD-H8Sl8yDUtL6VoZ4qJPKSQ_NDBAoE_6JE7-4Ef353utpAygCZVJMUKiLNs_evC-y2oezOKRsH_njtFZW4FwPE2XoaFm14sdbtUkj1QsqivY6DSpGpsmTNCCs3twYxx-6_C-e1OWEcnd4x6SoBg59LmCUsWhocu739h_ppdLRR_wPjY
My requirements file is pointing to a forked version of django-social-auth so I could put some print statements around the error. The failure seems to occur after making a call to
https://graph.facebook.com/oauth/access_token?code=AQCc6tIfxJTQN64GGQsDVbT4BCK1hYGypw2oMFQjjMQf-kfJqrWtI-vGe78fJJJHTL6w5yuau90vQu8msVGDpZh30HgUYkwdXhAKJcC9MCf8h6bp1e23wxkkMzP5eaT2j7xOCorn-KgeRv-ZJA40U87GDx1_592amAlSemS4zhXaoAv7JWRHl9NzBFtJ6cuGdbg&client_secret=[app_secret]&redirect_uri=http%3A%2F%2F[site_url]%2Fcomplete%2Ffacebook%2F%3Fredirect_state%3DDHlD9efEDau286xRGn2HtVpZ9AbooD3y&client_id=[app_id]
The error I'm getting from that is
{
"error": {
"message": "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request",
"type": "OAuthException",
"code": 100
}
}
However if i add a slash to the end of the url I get this error:
{
"error": {
"message": "Error validating application. Invalid application ID.",
"type": "OAuthException",
"code": 101
}
}
I assure you that app_id is correct
I know this has been a long read but does anyone have any suggestions on how to fix this?
#omab was correct, my issue was attaching the redirect_uri. It addition to that I had edited django-social-auth to append a backslash to the url. This was also incorrect.
Related
First I auth my user, which has role instagram Test Users, got access token by doint request to https://api.instagram.com/oauth/access_token Follow Getting Started guide.
Make a request to get user data https://graph.instagram.com/me?fields=username&access_token={{ACCESS_TOKEN}}
Everything OK, got 200 status and data.
Now tried to follow API Stories Docs
make a request to: https://graph.facebook.com/{{IG_ID}}/stories?access_token={{ACCESS_TOKEN}} (IG_ID is the ID I got from user data request) but doesn't work return invalid access token
{
"error": {
"message": "Invalid OAuth access token - Cannot parse access token",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "{ID}" //im not sure if important to hide
}
}
Now tried to use Explorer Api Graph (Tools->Explorer) I generate an access token (this token is generated with Facebook, not instagram), use this token and the ID (/me in Explorer API) in previous request and the response is:
//https://graph.facebook.com/{{ID}}/stories?access_token={{TOKEN}}
{
"error": {
"message": "(#100) Tried accessing nonexisting field (stories) on node type (User)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "{ID}"
}
}
Maybe I'm misunderstanding the guide, anyone have worked with API?
Hmmm... Does API works with private/public accounts? Or only if account is Business/Content Creator might use this?
I am getting Invalid platform app error while hitting oauth/access_token API on postman.
Note - for app_id i am using Instagram App Id.
Any solution for this?
{
"error_type": "OAuthException",
"code": 400,
"error_message": "Invalid platform app"
}
https://api.instagram.com/oauth/access_token?app_id=54219xxxxx359344&app_secret=190fac2eaacxxxxxxxxxd83e1cc0c382ec7&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fankush2016.github.io%2F&code=AQBSckcUcZ6edpLQlnt2NBCFgfhyJYfEBNW_cFlseJ0R7P2fisA3OWAMU8-BJXbFh0RrKdX0Z7ccrpK7rbZOyQID8epfqcpIGGbUn4oAcdC-sCBYEn2nvuPpjlXoSg5Quv-lq1uiucbqIGKoxH0mDkKDp_QKxxxxxxxxxxxxxxxxxxxxelPn1FoVJqSWqaKbVDtt9rdDlP4n0-aRg__exYWGJ8vqKnp_8dGNxg
In pseudo code format you may wish to use following configuration for your request:
baseURL = "https://api.instagram.com/oauth/access_token"
append = "client_id=\(API.INSTAGRAM_CLIENT_ID)&client_secret=\(API.INSTAGRAM_CLIENTSERCRET)&grant_type=authorization_code&redirect_uri=\(API.INSTAGRAM_REDIRECT_URI)&code=\(code)"
request.httpMethod = "Post"
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField:"Content-Type");
guys im working on django-rest-social-auth that is here in github
https://github.com/st4lk/django-rest-social-auth
and trying to add google login to my django rest framwork app
first i get code from this url
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={{CLIENT_ID}}&redirect_uri={{REDIRECT_URL}}&scope=email
then
i send needed parameter like clientId,redirect_uri,provider and code to
http://localhost:8000/api/login/social/jwt/google/
with postman and browser form but :
i get HTTP 400 Bad Request error also i see this in my server console :
raise AuthForbidden(args[0])
social_core.exceptions.AuthForbidden: Your credentials aren't allowed
this is the data that i post :
{
"clientId": "61235520-pn78ds5sds5d21d21jmn1e9.apps.googleusercontent.com",
"redirect_uri": "http://localhost:4200/",
"provider": "google-oauth2",
"code": "4%2Fto7CCGznNFgE-rsssPlEQzV3lY9yjUWW_85YmPWF4OU"
}
why ???
I am learning Rest web services using Postman extension of Chrome. I'm practicing it using Facebook API. I have a question about posting in FB.
URI used: https://graph.facebook.com/me/feed?
In the Body of the POST Method, I have given the following Json content
{
"message": "hello",
"access_token": "<a valid token>"
}
I am very sure that my access token is correct as when I append the access token and message with the above URI, the status gets posted successfully. Also when I use it as key-value pairs in 'x-wwww-form-urlencoded' section, it works fine.
But when I try to update the status using the Body of the POST method with the JSON content mentioned above, it tells
{ "error": { "message": "An active access token must be used to query information about the current user.", "type": "OAuthException", "code": 2500 } }
Is there any thing wrong in the format of the JSON content
I missed content-type=application/json
in the Header section.
Adding this solved the problem
I'm using OSQA and I simply trying to login with Facebook (without any change on the platform code), only setting 'app secret' and 'app id'.
My Facebook App settings:
Site URL: http://localhost:8080/osqa/
Canvas URL: http://localhost:8080/osqa/osqa/account/facebook/done/
I encounter this error:
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException",
"code": 191
}
}
and this is the url with the redirect_uri
https://graph.facebook.com/oauth/authorize?scope=email&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2Fosqa%2Fosqa%2Faccount%2Ffacebook%2Fdone%2F&client_id=***
I read a lot of posts concerning this problem here on stackoverflow and in other forums, I know there is a simple solution, but cannot figure out yet.
The redirect in your URL translates to this:
redirect_uri=http://127.0.0.1:8080/osqa/osqa/account/facebook/done/
Facebook just checks the strings and sees that 127.0.0.1 is not the same as localhost. So replace this in your app settings and the redirect should work.