У меня есть firebase проекта, который Im пытаясь проверить подлинность моих рельсов сервера создает пользовательский маркер с библиотекой рубинового JWT, как он говорит о документации, но я постоянно получаю ту же ошибку:Firebase аутентификации с помощью пользовательских маркеров
auth/invalid-custom-token, The custom token format is incorrect. Please check the documentation.
credentials.json
из учетной записи службы, которую я сделал на консоли Google, uid отправляется с лицевой стороны на api.
def generate_auth_token(uid)
now_seconds = Time.now.to_i
credentials = JSON.parse(File.read("credentials.json"))
private_key = OpenSSL::PKey::RSA.new credentials["private_key"]
payload = {
:iss => credentials["client_email"],
:sub => credentials["client_email"],
:aud => 'https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit',
:iat => now_seconds,
:exp => now_seconds+(60*60), # Maximum expiration time is one hour
:uid => uid.to_s,
:claims => {:premium_account => true}
}
JWT.encode(payload, private_key, 'RS256')
end
это выглядит в jwt.io
{
"iss": "[email protected]",
"sub": "[email protected]",
"aud": "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
"iat": 1486824545,
"exp": 1486828145,
"uid": "4",
"claims": {
"premium_account": true
}
}
Как выглядит маркер? Вы проверили его на jwt.io? – jps
Я только что отредактировал, как это выглядит в jwt.io –