1

I try to get access token on Facebook API.

According to this answer I need first to build a link https://www.facebook.com/dialog/oauth?client_id=[Your API KEY]&redirect_url=[Service that will handle Authentication]&scope=[Permissions you Need]. In my case it looks like this:

https://www.facebook.com/dialog/oauth?client_id=559149457475028&redirect_uri=http://www.facebook.com/connect/login_success.html&scope=publish_stream

After this it should redirect to specified url with a query string containing code, which in turn can be used to get access token of a user. But in my case it redirects to the following page: http://www.facebook.com/connect/blank.html#_=_ without any queries.

Why is that? How I can get code of a user?

3 Answers 3

1

your redirect_uri shouldn't be http://www.facebook.com/connect/login_success.html it should be a url from your application that would handle facebook authentication

update

if you are still developing your website and you want to test it on your local host you could use localhost/mydevwebsite/login_success/ otherwise use the domain for the application you are working on myappdomain.com/loginsuccess/

Sign up to request clarification or add additional context in comments.

8 Comments

It's not me. Where can I read about making this url? Can I find code or access token in a different way?
if you are still developing your website and you want to test it on your local host you could use localhost/mydevwebsite/login_success/ other wise use the domain for the application you are working on
I've also edited the question to include this comment, as it might be helpful
Indeed, with site URL it redirects with query string.
Will it increase your reputation?
|
0
  1. Access the signed_request parameter and prompt the user to authorize your app:

    $app_id = "YOUR_APP_ID";
    
    $canvas_page = "YOUR_CANVAS_PAGE_URL";
    
    $auth_url = "https://www.facebook.com/dialog/oauth?client_id=" 
        . $app_id . "&redirect_uri=" . urlencode($canvas_page);
    
    $signed_request = $_REQUEST["signed_request"];
    
    list($encoded_sig, $payload) = explode('.', $signed_request, 2); 
    
    $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
    
    if (empty($data["user_id"])) {
        echo("<script> top.location.href='" . $auth_url . "'</script>");
    } else {
        echo ("Welcome User: " . $data["user_id"]);
    } 
    
  2. This signed_request contains whole damn required information (including access token).

3 Comments

I have no experience working in PHP. Can you translate it to Python?
And I've no exp with python, but Ill explain you the concept. $signed_request = $_REQUEST["signed_request"]; step triies to fetch the variable singed_request from the url; if it is found, you can save the access token and perform functions, else it will redirect user to auth_url for the authorization step and the process is repeated.
This might be useful: stackoverflow.com/questions/464040/…. But I'm not sure
0

https://www.facebook.com/dialog/oauth?client_id=[Your API KEY]&redirect_url=[Service that will handle Authentication]&scope=[Permissions you Need].

1 Comment

Welcome to Stack Overflow! While this may help answer the question, it would be preferable to include more of an explanation.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.