Firebase Auth ID token has incorrect “aud” claim (AppCheck)

I am trying to integrate App Check in my self hosted backend. On the client side (Android app), I have followed this guide to get the App Check token. Here is the code that I am using:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Firebase.appCheck.getAppCheckToken(false).addOnSuccessListener { appCheckToken ->
val token = appCheckToken.token
}
</code>
<code>Firebase.appCheck.getAppCheckToken(false).addOnSuccessListener { appCheckToken -> val token = appCheckToken.token } </code>
Firebase.appCheck.getAppCheckToken(false).addOnSuccessListener { appCheckToken ->
            val token = appCheckToken.token
        }

I am sending the token to my backend with the request. On my backend (AWS lambda function), I have followed this guide to verify the token. Here is the code that I have used for verifying the token on the backend:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>cred = credentials.Certificate("serviceaccountkey.json")
firebase_admin.initialize_app(cred)
def lambda_handler(event, context):
print(event)
app_check_token = event['headers'].get('x-firebase-appcheck', 'abc')
try:
decoded_token = auth.verify_id_token(app_check_token)
response = handle_request(event)
except (ValueError, jwt.exceptions.DecodeError) as e:
response = {
'statusCode': 401,
'body': 'Unauthorized'
}
print(e)
print(response)
return response
</code>
<code>cred = credentials.Certificate("serviceaccountkey.json") firebase_admin.initialize_app(cred) def lambda_handler(event, context): print(event) app_check_token = event['headers'].get('x-firebase-appcheck', 'abc') try: decoded_token = auth.verify_id_token(app_check_token) response = handle_request(event) except (ValueError, jwt.exceptions.DecodeError) as e: response = { 'statusCode': 401, 'body': 'Unauthorized' } print(e) print(response) return response </code>
cred = credentials.Certificate("serviceaccountkey.json")
firebase_admin.initialize_app(cred)

def lambda_handler(event, context):
    print(event)
    app_check_token = event['headers'].get('x-firebase-appcheck', 'abc')
    try:
        decoded_token = auth.verify_id_token(app_check_token)
        response = handle_request(event)
    except (ValueError, jwt.exceptions.DecodeError) as e:
        response = {
            'statusCode': 401,
            'body': 'Unauthorized'
        }
        print(e)
        print(response)
    return response

I am getting this error when I call the API:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>[ERROR] InvalidIdTokenError: Firebase ID token has incorrect "aud" (audience) claim. Expected "projects/my_project_id" but got "['projects/my_project_number', 'projects/my_project_id']". Make sure the ID token comes from the same Firebase project as the service account used to authenticate this SDK. See https://firebase.google.com/docs/auth/admin/verify-id-tokens for details on how to retrieve ID token.
</code>
<code>[ERROR] InvalidIdTokenError: Firebase ID token has incorrect "aud" (audience) claim. Expected "projects/my_project_id" but got "['projects/my_project_number', 'projects/my_project_id']". Make sure the ID token comes from the same Firebase project as the service account used to authenticate this SDK. See https://firebase.google.com/docs/auth/admin/verify-id-tokens for details on how to retrieve ID token. </code>
[ERROR] InvalidIdTokenError: Firebase ID token has incorrect "aud" (audience) claim. Expected "projects/my_project_id" but got "['projects/my_project_number', 'projects/my_project_id']". Make sure the ID token comes from the same Firebase project as the service account used to authenticate this SDK. See https://firebase.google.com/docs/auth/admin/verify-id-tokens for details on how to retrieve ID token.

Here, my_project_id is the id of my Firebase’s project and my_project_number is the number of my Firebase’s project.

Anyone with the slightest idea what could be wrong? Sincere apologies if this has been asked before or is trivial in any other way.

I have tried regenerating the google-services.json, serviceaccountkey.json files. Still getting the same error.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật