Firebase auth custom token iOS
Asked Answered
B

1

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?

Bonny answered 16/7, 2016 at 7:56 Comment(4)
can you post your code for create custom token ....Articulation
i get token from VK servers, in resultBonny
no you have to create token with firebase.auth().createCustomToken(uid); for firebase ... then its working for youArticulation
I cant find any createCustomToken method. in documentation i saw it only in server configurationBonny
A
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

Articulation answered 16/7, 2016 at 8:50 Comment(3)
can i use VK authorization with Firebase without running server? as i understand, createCustomToken method from documentation is only for my own serverBonny
@EugeneStrelnikov I dont think so ... but I never tried that and dont know much about itArticulation
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! :)Relevance

© 2022 - 2024 — McMap. All rights reserved.