Google says it supports PKCE for OAuth 2.0 (see docs). However the Google PKCE flow requires a client secret, which is against the PKCE standard and potentially dangerous when the client is a mobile or desktop application, which is what I have.
This appears to be a long-standing issue... see this SO question from 2020.
A few questions:
- Is it safe to store the client secret on a mobile or desktop client when using the Google PKCE flow? Someone in the SO question linked above suggests it may be:
yes that's the point of PKCE ... the 'client secret' is not considered to be secret. Whether Google forced you to provide one or not, it isn't ultimately trusted.
Another SO answer also suggests this:
it is ok to not keep "client secret" a secret. The type of clients that do not keep confidentiality of client secret is called "public client" in the OAuth2 spec. The possibility of someone malicious being able to get authorization code, and then access token, is prevented by the following facts: (1) Client needs to get authorization code directly from the user, not from the service (2) Redirect URL is registered with client id/secret
A third SO answer suggests "the client secret is much more important for server-side apps than client-side apps".
- If not, is it safer to use the implicit flow? The top rated answer in the SO question linked above suggests this (but that was back in 2020):
SPAs are still directed to use the implicit flow in Googles' online documentation: https://developers.google.com/identity/protocols/oauth2/javascript-implicit-flow).
According to my understanding, the implicit flow has a few major downsides: (1) it does NOT support refresh tokens (see here) which can make for a bad user experience and (2) it has been largely deprecated in favor of PKCE (see here).
- Any insight into why Google PKCE requires a client secret when it clearly goes against the standard?