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

Google oauth, is it working? #54

Open
trungtin opened this issue Feb 6, 2016 · 5 comments
Open

Google oauth, is it working? #54

trungtin opened this issue Feb 6, 2016 · 5 comments

Comments

@trungtin
Copy link

trungtin commented Feb 6, 2016

This code from src/universal/modules/auth/ducks/auth.js:

export function oauthLogin(providerEndpoint, redirect) {
  ...
    const res = await fetch(hostUrl() + providerEndpoint, {
      method: 'get',
      mode: 'no-cors',
      credentials: 'include'
    });
   ...
}

if mode is 'no-cors' then response will be opaque:
An opaque filtered response is a filtered response whose type is "opaque", url list is the empty list, status is 0, status message is the empty byte sequence, header list is the empty list, body is null, and cache state is "none".https://fetch.spec.whatwg.org/#concept-filtered-response-opaque
then how can you examine response? And what if browser hadn't login Google before? And Google oauth2 not support 'cors', then the only way is open new tab then write access token in localStorage, right? And listening on localStorage events in current tab. I'm trying to make this work.

@mattkrick
Copy link
Owner

works fine for me, if it doesn't work for you i'm open to a PR

@trungtin
Copy link
Author

Sorry, I'm few days late to make a simple pull request. We're celebrating New Year here, made me forgot all of this :).
#57 Here the pull.

@bnchdrff
Copy link

i'm also experiencing this bug when trying to log in with a browser that isn't already signed into google

maybe related to electron/electron#1990?

@cometta
Copy link

cometta commented Apr 1, 2016

I experienced error at this line in chrome/firefox browser after clicked 'login with google'. Check browser console log. Let me know if anyone else experiencing this.

file: /src/universal/modules/auth/ducks/auth.js

    let res = await fetch(hostUrl() + providerEndpoint, {
      method: 'get',
      mode: 'no-cors',
      credentials: 'include'
    });

    let parsedRes = await parseJSON(res);  //Unhandled promise rejection SyntaxError: Unexpected end of input(…)

@mattkrick
Copy link
Owner

yeah, like @trungtin said i should probably use CORS as no-cors will be opaque. I forget all the right settings & IIRC the native fetch was doing something weird. If anyone has time to investigate further, this would make an awesome PR!

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

No branches or pull requests

4 participants