meatier
meatier copied to clipboard
Google oauth, is it working?
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.
works fine for me, if it doesn't work for you i'm open to a PR
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.
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?
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(…)
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!