1

EDIT - Closer. Need to have a port number for my callback url.

i.e. http://127.0.0.1:1234

Problem is that port is dynamic and constantly changing. Has anyone ran into this before?


Working with rhomobile. Need some help to better understanding how facebook oauth2 works.

when user launches app for the first time want to do facebook connect to get user info and post to wall when user comments.

Assume I can do the following:

Have a button which calls an Action in my Controller. -> Action launches WebView to FB mobile for authentication -> User enters credentials on FB -> on redirect_uri_controller gets auth_code and I do a AsyncHttp.get requesting token with another redirect_url -> lands redirect_url & auth_token stored.

Right now, have a button that calls the below controller

def fb_initiate_connect
  call_back_url = url_for(:controller => "Settings", :action => :fb_initiate_connect_callback)
  url = "http://www.facebook.com/dialog/oauth?client_id=#{fb_app_id}&redirect_uri=#{call_back_url}&scope=email,read_stream,publish_stream&display=touch"
  WebView.navigate(url)
end

This launches a UIWebview in my app, goes to FB mobile site but getting "An error occurred with APP_NAME. Please Try again later."

Think its because cookie is not being set/found? Everything in here is pretty much manual so would have to do something like WebView.execute_js("document.cookie=WHAT?;") But do I put this in my call_back_url or fb_initiate_connect?

pcasa
  • 3,710
  • 7
  • 39
  • 67
  • Which platforms are you testing with? With Android, with the app loaded in the emulator, you can forward it to your local machine so you can check the URL that you are getting sent to, and it will also help you better debug javascript and css issues. The command is: adb forward tcp:8080 tcp:8080 – Geoffrey Jun 21 '11 at 19:36
  • Also, see this thread for similar functionality: [link](http://stackoverflow.com/questions/6353419/rhomobile-and-oauth2/) – Geoffrey Jun 21 '11 at 19:38
  • Tried that, but didn't work. Guess first question should be is can I even do oauth dialog calls to facebook without using cookies? – pcasa Jun 23 '11 at 13:51
  • Why aren't you using cookies? Are they disabled on the device? – Geoffrey Jun 23 '11 at 19:25
  • Seems that soo. Did edit question. Problem stems from port number required on the callback url. – pcasa Jun 23 '11 at 21:52

1 Answers1

0

Yes, Rhodes dynamically configures the port because specifying an explicit port may conflict with another port being used on the device by another Rhodes application or anything else on the device.

You can force the port on which your application runs in the RhoConfig.txt, with the property:

local_server_port = 8080

However, the best solution would be to get the dynamic server port by:

System.get_property('rhodes_port') 
Geoffrey
  • 562
  • 4
  • 9
  • edited RhoConfig.txt with `local_server_port = 50505` but still getting dynamic ports. any idea? – pcasa Jun 24 '11 at 16:55
  • Take it back. Does work but not all the time. Sometimes it still reverts back to dynamic. – pcasa Jun 24 '11 at 17:40
  • I would let it keep creating it dynamically, and just use the System.get_property('rhodes_port') to access it. – Geoffrey Jun 27 '11 at 21:52