question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when trying to login in with Google

See original GitHub issue

Issue and Steps to Reproduce

Create a Google OIDC client and try to use it with this library:

import {Provider} from "react-redux";
import {OidcProvider} from "@axa-fr/react-oidc-context";

const oidcConfig = {
	client_id: 'your_google_client_id',
	redirect_uri: `${location.protocol}//${location.host}/`,
	scope: 'openid',
	authority: 'https://accounts.google.com',
	service_worker_only: false
};

const root = createRoot(document.getElementById('root'));
root.render(
	<Provider store={store}>
		<OidcProvider configuration={oidcConfig}>
			<App/>
		</OidcProvider>
	</Provider>
);

Versions

Tried in version 5.3.1

Expected

Redirect to Google SSO

Actual

Before the actual redirect, the following error occurs because sessionStorage is empty:

SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.loadItemsAsync (initSession.ts:9:1)
    at Oidc.<anonymous> (oidc.ts:419:1)
    at step (noHashQueryStringUtils.ts:3:1)
    at Object.next (noHashQueryStringUtils.ts:3:1)
    at fulfilled (noHashQueryStringUtils.ts:3:1

Additional Details

I use React-Saga within my React application

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
timwsuqldcommented, Oct 18, 2022

@guillaume-chervet thanks, I’ve worked out that we just need to use useOidcIdToken instead of useOidcAccessToken when using Google for OIDC. Hopefully this comment helps someone else stumbling across this issue.

1reaction
jensajacommented, Apr 24, 2022

Thank you so much @guillaume-chervet . I wish I found the example earlier 😃

One more issue though: the token request succeeds. But when trying to parse the response, the extractAccessTokenPayload method fails when trying to perform an atob operation on the returned token. The following exception occurs:

Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

Is this a known issue? The access token returned by Google looks like this: ya29.A0ARrd...

Edit: it looks like Google isn’t using a JWT as access token, while the library expects this (?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't sign in from a third-party service - Google Account Help
Your sign-in may be blocked if the device or location you're using is new. Try again from a device or location that you...
Read more >
How To Fix Google Sign In Error On Android - velog
How to Fix Google login error on Android ... Existing app cache / data issues - As someone suggested, this can be resolved...
Read more >
Google sign-in error on android phone - Error Solutions
Google sign-in error on android phone is an error that may simply be a sign-in issue, which sometimes occurs when the Play Store...
Read more >
How To Fix Google Sign In Error On Android | 01 - Vocal Media
The error may simply be a login issue that sometimes occurs when updating the Play Store. The first trick is to go to...
Read more >
FAQ: Why did I receive a Google Authentication Error?
The first thing you should try is refreshing your browser window, potentially even clearing your browser cache and then try to perform the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found