meatier icon indicating copy to clipboard operation
meatier copied to clipboard

Google oauth, is it working?

Open trungtin opened this issue 9 years ago • 5 comments
trafficstars

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.

trungtin avatar Feb 06 '16 07:02 trungtin

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

mattkrick avatar Feb 06 '16 13:02 mattkrick

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.

trungtin avatar Feb 10 '16 09:02 trungtin

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

maybe related to https://github.com/atom/electron/issues/1990?

bnchdrff avatar Mar 18 '16 21:03 bnchdrff

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(…)

cometta avatar Apr 01 '16 09:04 cometta

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!

mattkrick avatar Apr 02 '16 23:04 mattkrick