-
Notifications
You must be signed in to change notification settings - Fork 409
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
Hybrid Authentification returning null #122
Comments
Not sure why this is happening, but I am noticing that some of the code in the sample isn't in your coffeescript version. The url in the ajax call should be: https://apis.google.com/js/client:plus.js?onload=gpAsyncInit Also make sure you have the API's you need enabled in the console. They are listed in the README. |
So it looks like you're attempting to replace the onload function in the URL with a promise that resolves when the AJAX call returns. This conflates two different events:
onload refers to the 2nd of these events, but your promise resolves on the 1st. Note that we don't use a promise (or callback) in the $.ajax function call in the example. We don't do that for exactly this reason. |
@zquestz I tried using both methods ( @petergoldstein the result is the same when I don't use a promise. I literally copied and pasted the code from your example into my code (escaped the javascript using the ` character), and the result was still the same. :-/ The code I'm trying now (which still fails) looks like this:
|
So the part that is failing is pretty easy to test. In fact you are breaking before this gem even gets used. Perhaps just try in the javascript console and see if you can get gapi.auth.authorize() to work. Here are the docs for the part failing: The gem is only used in the callback from gapi.auth.authorize(). The rest should be covered by the doc above. Good luck and let me know if anything in the docs needs to be updated. |
@zquestz I've got it working now, and the reason was indeed as you said that I was calling the API itself incorrectly - thank you very much for pointing that out! The problem it seems was that I was not setting the Anyway, the following code is working for me now, in case you want to update the docs regarding API keys and whatnot.
|
A new problem I've encountered once I got it working was the following:
Does that mean the app using this gem has to run on |
You should definitely try with immediate set to true. I know there are issues with the popup if this isn't done. |
This was also on stack overflow, if you use this extension: https://stackoverflow.com/questions/21118527/chrome-protocols-must-match-error-when-running-google-cloud-endpoints-web-clie |
That seems to have fixed it, @zquestz (immediate: true) - thank you very much for taking the time to reply :-) |
immediate: true does not fix it completely for me. |
I have the same problem as @raldred |
I wonder if this a recent issue, either something new in omniauth or Google's api |
@raldred as far as I know hybrid client authentication for this gem came with this PR #50 in the past year. I finally get it works. The solution is not very nice, but at least it works any way. You just need to add two authorize actions, first with immediate false and the last one with immediate true. For example:
|
@gkopylov & @raidred is this the best way to do that? Has anything changed to make this better? |
@mmahalwy I never found a solution unfortunately and I don't understand the inner workings of omni auth and this lib to fix. |
@raldred I think it is not related to this gem. As you can see it is just a client side flow. Unfortunately, when I posted solution above, I didn't take a close look into official google implementation and just experimented with code in the readme. So when you look at the official google readme https://developers.google.com/api-client-library/javascript/features/authentication#Authexample you can find that there are also two authorize actions with immediate false and immediate true. |
K after looking into this again, it seems clear the path forward. I am going to put in some fixes for the README. Will close once this is updated. |
I'm trying to use the Hybrid Authentification, but the response I get from the Google Plus API is always
null
.Anything in particular I am doing wrong/misunderstanding?
The text was updated successfully, but these errors were encountered: