6

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?

Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108

1 Answers1

3

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

Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
  • can i use VK authorization with Firebase without running server? as i understand, createCustomToken method from documentation is only for my own server – Eugene Strelnikov Jul 16 '16 at 08:59
  • 1
    @EugeneStrelnikov I dont think so ... but I never tried that and dont know much about it – Bhavin Bhadani Jul 16 '16 at 09:03
  • Hey @EICaptainv2.0, I am trying to log my user in with username and password only, like in Instagram, how can I do this? I am kinda new to swift and I kinda didn't understand your answer, hope you can help me out! :) – Abdullah Ajmal Jun 14 '19 at 14:17