资源上的权限“cloudmessaging.messages.create”被拒绝

问题描述 投票:0回答:1

我正在尝试向我的应用程序添加通知
该应用程序是Android,我正在尝试使用postman测试通知发送
我通过控制台应用程序接收我的授权承载并在邮递员中使用它进行测试
这是授权持有者的代码

public static async Task<string> getToken()
{
    try
    {
        // Create an explicit ServiceAccountCredential credential
        var credential = await GoogleCredential.FromFile({pathToJsonFile})                                            
                     .CreateScoped("https://www.googleapis.com/auth/firebase.messaging")
                     .UnderlyingCredential
                     .GetAccessTokenForRequestAsync();

        return credential;
    }
    catch (Exception ex)
    {
        return "";
    }
}

{pathToJsonFile}
包含我从
console.cloud.google.com
站点获取的密钥文件,用于我创建的
service_account
我赋予了
service_account
 
owner
Service Account Admin
 角色
我正在尝试通过邮递员发送通知

项目名称(隐藏在url中的蓝色部分)我从

console.firebase.google.com/project/.../

得到的

{ "message": { "token": "{tokenIGotFromAndroidDevice}", "notification": { "title": "body", "body": "Title" }, "data": { "type": "1", "message": "message" } } }
但是我收到以下回复

{ "error": { "code": 403, "message": "Permission 'cloudmessaging.messages.create' denied on resource '//cloudresourcemanager.googleapis.com/projects/...' (or it may not exist).", "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "IAM_PERMISSION_DENIED", "domain": "cloudresourcemanager.googleapis.com", "metadata": { "resource": "projects/...", "permission": "cloudmessaging.messages.create" } } ] } }
    
c# json firebase firebase-cloud-messaging
1个回答
0
投票
使用项目 ID 而不是项目名称

© www.soinside.com 2019 - 2024. All rights reserved.