问题
First i'd just like to say I have Google play sign in up and working. However I have struggling to understand how a specific line of code works.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
I would like to know how requestIdToken is getting my real clientId.
when investigating: default_web_client_id = 0x7f060035
when i log R.string.default_web_client_id i get: 2131099701
when I log getString(R.string.default_web_client_id) i get: xxxxxxx-xxxxxxxxx0tfctc0fa0a.apps.googleusercontent.com(my web client id)
This id is not located in my strings or resources folder. However it is in my google-services.json file.
My question is how is getString or that default_web_client_id resolving into a clientID in a Json File?
Thanks in advance for the enlightenment!
回答1:
According to this you apply gradle plugin which then generates new xml file with values from the JSON
回答2:
For the first time when you close the project after integration of Firebase with the project. DEFAULT_WEB_CLIENT_ID possibly removed from the project.
So you have to add default_web_client_id manually.
go to
res-->strings--> values
and Add the string like this
<string name="default_web_client_id" translatable="false">237047375768-ma9cm63bn9goidlu99jl3fen5f6mieru.apps.googleusercontent.com</string>
You can also watch this video for more detail
来源:https://stackoverflow.com/questions/38825748/how-does-google-services-json-replace-default-web-client-id