Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase auth custom token iOS

I am trying to add to my app VK authorization with Firebase SDK.

When user authorization finished, I try to pass token to Firebase.

func vkSdkAccessAuthorizationFinishedWithResult(result: VKAuthorizationResult!){

        let tokenString = result.token.description
        FIRAuth.auth()?.signInWithCustomToken(tokenString) { (user, error) in
            // ...

        }
    }

Error: [1] (null) "NSLocalizedDescription" : "The custom token format is incorrect. Please check the documentation."

Can I use Firebase with custom auth without running server?

like image 954
Eugene Strelnikov Avatar asked Jul 16 '16 07:07

Eugene Strelnikov


People also ask

How do I get Firebase bearer token?

The access tokens can be generated using a service account with proper permissions to your Realtime Database. Clicking the Generate New Private Key button at the bottom of the Service Accounts section of the Firebase console allows you to easily generate a new service account key file if you do not have one already.


1 Answers

From Firebase Doc. Create custom tokens using the Firebase SDK,

I would say that you need to use createCustomToken() method for this.. you can not use your VK servers token to signIn with firebase ... you need to generate token for firebase with createCustomToken() method.

 var uid = "some-uid";
 var customToken = firebase.auth().createCustomToken(uid);

May this work for you

like image 196
EI Captain v2.0 Avatar answered Nov 07 '22 12:11

EI Captain v2.0