2016-10-11 6 views
2

Я использую Google для аутентификации, Google, как следующее:Realm SyncUser.authenticate неудачу с ClientId и Facebook

let credential = Credential.google(token: "<SOME-HASH-HERE>.apps.googleusercontent.com") 
SyncUser.authenticate(with: credential, server: serverURL, timeout: 60) { [weak self] user, error in 
    guard nil == error else { 
     print("error while authenticating: \(error!)") 
     return 
    } 
    … 
} 

Это дает ошибку 400. После некоторых отладки я нашел больше информации о проблеме, но все-таки не уверен, что с этим не так. Так ответ выглядит следующим образом:

{ 
    "invalid_params":[ 
    { 
     "name":"provider", 
     "reason":"Unknown provider!" 
    } 
    ], 
    "status":400, 
    "type":"https://realm.io/docs/object-server/problems/invalid-parameters", 
    "title":"Your request parameters did not validate!", 
    "code":601 
} 

Вот тело запроса:

{ 
    "provider":"google", 
    "app_id":"com.blabla.bla-bla-bla", 
    "data":"<SOME-HASH-HERE>.apps.googleusercontent.com" 
} 

Я взял аутентификацию код из примера с официальной документации, и я использую последнюю версию базы Realm.

Я также проверил аутентификацию с помощью Facebook, но она дает такую ​​же ошибку.

Я проверил файл configuration.yml на сервере и удалил google и facebook, разместил необходимые данные и перезапустил систему. Не помогает.

Есть ли у кого-то такая же проблема?

PS: configuration.yml (только часть с providers):

# Realm Object Server Configuration 
# 
# For each possible setting, the commented out values are the default values 
# unless another default is mentioned explicitly. 
# 
# Paths specified in this file can be either absolute or relative. 
# Relative paths are relative to the current working directory. 

    providers: 
    ## Providers of authentication tokens. Each provider has a configuration 
    ## object associated with it. If a provider is included here and its 
    ## configuration is valid, it will be enabled. 

    ## Possible providers: cloudkit, debug, facebook, realm, password 
    ## Providers 'realm' and 'password' are always enabled: 
    ## - The 'realm' provider is used to derive access tokens from a refresh token. 
    ## - The 'password' provider is required for the dashboard to work. It supports 
    ## authentication through username/password and uses a PBKDF2 implementation. 

    ## This enables authentication via a Google Sign-In access token for a 
    ## specific app. 
    google: 
     ## The client ID as retrieved when setting up the app in the Google 
     ## Developer Console. 
     clientId: '<SOME-HASH-HERE>.apps.googleusercontent.com' 

    ## This enables authentication via a Facebook access token for a specific app. 
    ## This provider needs no configuration (uncommenting the next line enables it). 
    facebook: {} 

После того как я сделал изменения в этом файле я назвал

sudo service realm-object-server restart 

И просто чтобы быть уверенным, я также перезагрузить систему.

+0

Пожалуйста размещать соответствующую конфигурацию сервера и информацию о том, как вы перезагрузили сервер. Спасибо – teotwaki

+0

Я только что обновил описание, пожалуйста, посмотрите –

+0

То же самое касается android. – Andy

ответ

5

К сожалению, в файле configuration.yml есть ошибка, которую я подозреваю, что вы нажимаете. Раздел providers: в файле конфигурации должен находиться в разделе auth: (а не внутри раздела network:, где он находится в отгруженном файле). Исправление состоит в том, чтобы просто переместить соответствующую конфигурацию поставщиков, чтобы жить под ключом auth:.

У нас есть исправление, готовое к этой ошибке, которая станет частью следующей версии Realm Object Server.

Вот пример фрагмент, показывающий полный auth: раздел с исправлением:

# Realm Object Server Configuration 
# 
# For each possible setting, the commented out values are the default values 
# unless another default is mentioned explicitly. 
# 
# Paths specified in this file can be either absolute or relative. 
# Relative paths are relative to the current working directory. 

auth: 
    ## The path to the public and private keys (in PEM format) that will be used 
    ## to validate identity tokens sent by clients. 
    ## These configuration options are MANDATORY. 
    public_key_path: /etc/realm/token-signature.pub 
    private_key_path: /etc/realm/token-signature.key 

    providers: 
    ## Providers of authentication tokens. Each provider has a configuration 
    ## object associated with it. If a provider is included here and its 
    ## configuration is valid, it will be enabled. 

    ## Possible providers: cloudkit, debug, facebook, realm, password 
    ## Providers 'realm' and 'password' are always enabled: 
    ## - The 'realm' provider is used to derive access tokens from a refresh token. 
    ## - The 'password' provider is required for the dashboard to work. It supports 
    ## authentication through username/password and uses a PBKDF2 implementation. 

    ## This enables authentication via a Google Sign-In access token for a 
    ## specific app. 
    google: 
     ## The client ID as retrieved when setting up the app in the Google 
     ## Developer Console. 
     clientId: '<SOME-HASH-HERE>.apps.googleusercontent.com' 

    ## This enables authentication via a Facebook access token for a specific app. 
    ## This provider needs no configuration (uncommenting the next line enables it). 
    facebook: {} 
+0

Не могли бы вы предоставить фрагмент того, как должен выглядеть файл конфигурации? – teotwaki

+0

Я только что попробовал, перезапустил систему, но это исправление не помогает. Ошибка остается той же –

+0

Сделала трюк для меня. – Andy

Смежные вопросы