New to FB dev, trying to get access token via Java (server-side flow) in local Eclipse/Tomcat environment
Developing locally with a tomcat server under eclipse. Goal is to use RestFB API kit to access user info on server side using Java. I've done a LOT of research across the web but I am stumped.
My app is set up with Site URL: http://localhost:8080/
Initial URL for user is:
www.facebook.com/dialog/oauth?client_id=155730431154731&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2FSircolBase%2Ffboauth%2F&scope=user_about_me,friends_about_me,offline_access
The user hits this URL and accepts the app. FB responds to my redirect URL which is a servlet via the following URL:
localhost:8080/SircolBase/fboauth/?code=Mf_kXCH3Lo5cGeBuWw_R1x_1b1EJmvoXJpieDqsOk2k.eyJpdiI6IkJvdHRIMmJJZUR0开发者_如何学PythoncXNIdFZCX1E5d0EifQ.bjPZvcmNVLhk4KcfRwJwWSYKv6GVOe9TbveHRRIEoQ3BwXneDAfTKyzY4jw2k8BdSOc19QjSNJ8PrEEyQ0Uuomh3f4Nn_GEk95wGGJcI6sLnFDIXyC0_n7IbeJeRtazN
I parse the code in the servlet and then build the oAuth GET request, which is:
graph.facebook.com/oauth/access_token?client_id=155730431154731&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2FSircolBase%2Ffboauth%2F&client_secret=xxxxxxd39227e77de9d8ef682abf299c&code=Mf_kXCH3Lo5cGeBuWw_R1x_1b1EJmvoXJpieDqsOk2k.eyJpdiI6IkJvdHRIMmJJZUR0cXNIdFZCX1E5d0EifQ.bjPZvcmNVLhk4KcfRwJwWSYKv6GVOe9TbveHRRIEoQ3BwXneDAfTKyzY4jw2k8BdSOc19QjSNJ8PrEEyQ0Uuomh3f4Nn_GEk95wGGJcI6sLnFDIXyC0_n7IbeJeRtazN
I execute the GET in Java and the response comes back as:
access_token=155730431154731|15d3fb5635abf840d87f7f75.1-570520241|kuj1yskauro43dmqspwh-rqktwa
I take the access token and try to do 2 calls, from the servlet on my local server immediately in java:
graph.facebook.com/me?access_token=155730431154731%7C15d3fb5635abf840d87f7f75.1-570520241%7Ckuj1yskauro43dmqspwh-rqktwa&format=json
graph.facebook.com/JonesJerryK?access_token=155730431154731%7C15d3fb5635abf840d87f7f75.1-570520241%7Ckuj1yskauro43dmqspwh-rqktwa
Both return with:
{"error":{"type":"OAuthException","message":"Invalid access token signature."}}
What am I doing wrong? Note that both redirect URL references along this sequence are encoded and identical. Does the access_token above look like it is in the correct format? Some have suggested that it is not. Note that I am requesting 'offline_access' in this app.
Thanks for any tips.
This seems way too complicated. You can use RestFB, or the Facebook Java API which have already encapsulated all the technical details for doing this.
精彩评论