8
私はFirebaseのJWTトークンをサーバー上でRubyを使って生成しようとしています。 3.0より前はtoken generatorを使用しましたが、アップグレード後に動作を停止しました。次のコードで取得するトークンにはエラーがあります。Firebaseトークンのエラー。「カスタムトークンは、異なるオーディエンスに対応しています。
The custom token corresponds to a different audience.
と私はそれが意味するところはどこにも見つかりません。
private_key = OpenSSL::PKey::RSA.new <<-PEM
-----BEGIN PRIVATE KEY-----
..redacted..
-----END PRIVATE KEY-----
PEM
service_account_email = '[email protected]'
now_seconds = Time.now.to_i
payload = {
iss: service_account_email,
sub: service_account_email,
aud: 'https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit',
iat: now_seconds,
exp: now_seconds + (60 * 60),
uid: self.id.to_s,
debug: true,
claims: {
userId: self.id,
slug: self.slug,
username: self.username,
avatar: self.profile.avatar.url,
group: self.group,
debug: true
}
}
JWT.encode payload, private_key, 'RS256'
おかげ
感謝を –