LinkedIn login with custom token ( ERROR_INVALID_CUSTOM_TOKEN )

I am trying to login with LinkedIn using the native app and the LinkedIn SDK. So far I can login using the web if the LinkedIn app is not installed. I can also login with LinkedIn and get a token in return. But when I try to authenticate with Firebase I get this error:

Optional(Error Domain=FIRAuthErrorDomain Code=17000 "The custom token 
format is incorrect. Please check the documentation." UserInfo=
{NSLocalizedDescription=The custom token format is incorrect. Please 
check the documentation., error_name=ERROR_INVALID_CUSTOM_TOKEN})

This is my code:

  • EXC_BAD_INSTRUCTION When Passing UICollectionView Cell Data to Different ViewController
  • Firebase Commit/Rollback for complex writes
  • Firebase: FIRApp.configure() keeps wanting me to change it to FirebaseApp.configure()
  • How to write to the last child of a Firebase ref in Swift?
  • Unable to upload Development APNs certificate
  • Cannot import Firebase in Swift app
  •         // App installed
            LISDKSessionManager.createSession(withAuth: permissions, state: nil, showGoToAppStoreDialog: true, successBlock: { (returnState) -> Void in
                LISDKAPIHelper.sharedInstance().getRequest(",first-name,last-name,email-address,picture-url,public-profile-url,industry,positions,location)?format=json", success: { (response) -> Void in
                    if let data = response? String.Encoding.utf8) {
                       if let dictResponse = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers){
                            let token = LISDKSessionManager.sharedInstance().session.accessToken.accessTokenValue
                            Auth.auth().signIn(withCustomToken: token!  ) { (user, error) in
                }, error: { (error) -> Void in
                    print("LINKEDIN error\(String(describing: error))")
            }) { (error) -> Void in
                print("error login linkedin")

    The token I am sending to Firebase is a String, so that should be okay. I must be missing something. But what ?

    Solutions Collect From Internet About “LinkedIn login with custom token ( ERROR_INVALID_CUSTOM_TOKEN )”

    The problem was my misunderstanding. I thought I could use the Linkedin token directly. It has to go to a webservice that uses the Firebase admin user to generate the token.