Java – how to retrieve Facebook auth code using restfb

I am using restfb to create a Java application

Basically, the steps are as follows:

>Redirect to Facebook as an example

https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email ,read_ stream

2. If I use the above URL to call the HTTP request, I will receive the following HTML response

3. However, if I call the above link through the browser, I will get the following URL containing OAuth code

What I really want is OAuth code. I can only get it through browser 3. I can't get it through browser 2 I want to programmatically get OAuth code in my stand - alone Java program How can I achieve this goal?

Solution

You cannot get OAuth code programmatically This code allows you to perform actions on behalf of licensed users

When redirecting the browser to the URL in step 1, the browser presents a dialog box, and the user presses allow or skip Only when the user allows and grants your application permission will you get OAuth code

The response you get at 2 may be the HTML of the screen you see at 3

In addition; Restfb has nothing to do with authentication After obtaining the access key, it becomes useful

Last but not least, you may need to view the desktop application portion of the document

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>