Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify the callback dataType #56

Closed
JNajera opened this issue Jun 3, 2014 · 4 comments
Closed

Specify the callback dataType #56

JNajera opened this issue Jun 3, 2014 · 4 comments

Comments

@JNajera
Copy link

JNajera commented Jun 3, 2014

It there's any way I can set the dataType for my callback at hello.login()? Because for some apps Im developing, i need to return it as JSON to my callback url.

Thanks in advance

@MrSwitch
Copy link
Owner

MrSwitch commented Jun 3, 2014

Erm... the library only works with json for some very good reasons. Why, do you see something else?

@JNajera
Copy link
Author

JNajera commented Jun 3, 2014

Sorry I didn't explain it well. Im using Ruby on Rails with Devise, so for make it work manually without reload the page I need to post back on my callback_url as JSON.
This is an example using the FB JSDK (Sorry i only have it on coffeescript)

$(document).ready ->
  $("#facebook-connect").click (e) ->
    e.preventDefault()
    FB.login (response) ->
      if response.authResponse
        $.getJSON '/auth/facebook/callback', (data) ->
          # Do more stuff for login

When I use the hello.js library, the Hello.login() function do the callback, but I receive on my server the callback as dataType = "text/html"

Started GET "/auth/facebook/callback" for 127.0.0.1 at 2014-06-03 10:47:10 -0500
Processing by Devise::OmniauthCallbacksController#facebook as HTML

Instead im looking to mod the dataType of the ajax callback, only for the login method, like dataType = "application/json"

Started GET "/auth/facebook/callback" for 127.0.0.1 at 2014-06-03 10:49:14 -0500
Processing by Devise::OmniauthCallbacksController#facebook as JSON

I hope now its more clear. Thanks for your response.

@MrSwitch
Copy link
Owner

MrSwitch commented Jun 3, 2014

Sorry its still hard to understand. If you want to change the xhr request in hello.api() then take a look at https://github.com/MrSwitch/hello.js/blob/master/src/modules/windows.js#L145

Since the OAuth flow works by opening pages with test/html, i fail to grasp what you mean when you say "post back on my callback_url as JSON.".

@MrSwitch
Copy link
Owner

@JNajera please comment and i'll reopen this if its still an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants