A client secret placed inside a mobile app is in the hands of anyone who downloads the app. The binary is opened and the string is read. That string is not the secret RFC 6749 assumes for a confidential client. The design treats it as if it were not a secret.
RFC 8252 writes down OAuth 2.0 for native apps. It does not recommend the implicit flow for a native app. It puts the authorization code flow in its place, with PKCE from RFC 7636. The app adds a challenge, derived from a verifier, to the authorization request. When the code is exchanged for a token, the same verifier is sent. Someone who intercepted the code does not have the verifier.
The redirect address is also under the app's control. RFC 8252 asks for an address the operating system delivers to the app, a claimed HTTPS scheme or the platform's return path. An arbitrary custom scheme can be claimed by another app that registered the same scheme. The token then goes to that app.
The token stays on the device. The refresh token is kept in the device's secure store and is not written to a log. On the server the token is bound to the user and the client identity. When the app is removed and installed again, the old refresh token is treated as invalid. That rule is written on the server.
When FenergyTech sets up a first-party mobile client, it does not put a client secret in the binary. The flow is authorization code with PKCE.
The steps of PKCE are short, and a skipped step gives the token away. The app generates a random verifier. The challenge is the digest of that verifier and it goes with the authorization request. When the user returns, the code is sent with the same verifier while asking for the token. Someone who intercepted the code does not have the verifier. RFC 7636 asks for the digest as S256. The plain method carries the verifier itself on the wire and erases the point of the digest.
The redirect address gives it away too. RFC 8252 asks for an address the operating system delivers to the app. An arbitrary custom scheme is a door that another app, registered for the same scheme, can also open. The token goes to that app. The scheme is bound to one app in the store record. Without that binding, the code falls to whichever app opens first.
Searching the binary for a string "client_secret" shows whether a secret is sitting there. If it is, the flow thinks it is a confidential client. The confidential client in RFC 6749 keeps the secret on the server. A secret kept on the phone is not a secret.
Sources: RFC 6749, The OAuth 2.0 Authorization Framework, IETF, 2012. RFC 7636, Proof Key for Code Exchange by OAuth Public Clients, IETF, 2015. RFC 8252, OAuth 2.0 for Native Apps, IETF, 2017.
Planning a similar project?
We can talk through how the topic in this article applies to your product.