0
我遵循link,並已完成上述服務器上的配置。Android:針對雲端點的Firebase身份驗證無法正常工作
"/users":
post:
description: "<Description>"
operationId: "<OperationID>"
produces:
- "application/json"
responses:
200:
description: "user List"
schema:
$ref: "#/definitions/echoMessage"
parameters:
- description: "Search Criteria"
in: body
name: message
required: true
schema:
$ref: "#/definitions/echoMessage"
security:
- firebase: []
和
firebase:
authorizationUrl: ""
flow: "implicit"
type: "oauth2"
x-google-issuer: "https://securetoken.google.com/<Project-ID>"
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/[email protected]"
並通過智威湯遜的標準去後,我才知道,同時呼籲調用服務,我們必須增加與承載Authorization頭,所以我已經添加了標題如下,
授權:承載
我起初嘗試了
String token = FirebaseInstanceId.getInstance().getToken();
但是所以我嘗試它給了錯誤,
FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
if (firebaseUser != null) {
firebaseUser.getIdToken(true)
.addOnSuccessListener(new OnSuccessListener<GetTokenResult>() {
@Override
public void onSuccess(GetTokenResult getTokenResult) {
String token = getTokenResult.getToken();
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putString(Constants.PREFS_FCM_TOKEN, token);
editor.apply();
}
});
}
但即使有兩個代碼,我得到錯誤爲401和INVALID_TOKEN