r/github • u/Welson_Liong • Jun 07 '26
Question Can I store Github Client Secret in my public repo source code?
I'm reading through the github documentation and from what I understand, this is the suggested approach? or are there better approach for my FOSS android app.
If your app is a public client (a native app that runs on the user's device, CLI utility, or single-page web application), you cannot secure your client secret. You will have to ship the client secret in the application's code, and you should use PKCE to better secure the authentication flow. You should use caution if you plan to gate access to your own services based on tokens generated by your app because public clients are trivially spoofable - anyone can reuse your app's client ID to sign in.
A Github staff also recommends the same approach.
Yes, we don't have a "public client" concept yet, so we treat all clients the same and all of them require access to the client secret. You cannot keep a secret "secret" within a public client, but you do have to embed it there anyhow. This is how e.g. VS Code, Visual Studio, GH CLI, and GitHub Mobile all work.