使用自定义令牌(ERROR_INVALID_CUSTOM_TOKEN)的LinkedIn登录 [英] LinkedIn login with custom token ( ERROR_INVALID_CUSTOM_TOKEN )
问题描述
我正在尝试使用本机应用程序和LinkedIn SDK登录LinkedIn.到目前为止,如果未安装LinkedIn应用程序,则可以使用Web登录.我也可以使用LinkedIn登陆并获得令牌.但是,当我尝试通过Firebase进行身份验证时,出现此错误:
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})
这是我的代码:
// App installed
let permissions = [LISDK_BASIC_PROFILE_PERMISSION,LISDK_EMAILADDRESS_PERMISSION]
LISDKSessionManager.createSession(withAuth: permissions, state: nil, showGoToAppStoreDialog: true, successBlock: { (returnState) -> Void in
LISDKAPIHelper.sharedInstance().getRequest("https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,picture-url,public-profile-url,industry,positions,location)?format=json", success: { (response) -> Void in
if let data = response?.data.data(using: 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
print(user!)
print(error!)
}
}
}
}, error: { (error) -> Void in
print("LINKEDIN error\(String(describing: error))")
})
}) { (error) -> Void in
print("error login linkedin")
}
我要发送给Firebase的令牌是字符串,因此应该可以.我肯定错过了什么.但是呢?
The token I am sending to Firebase is a String, so that should be okay. I must be missing something. But what ?
推荐答案
问题是我的误解.我以为我可以直接使用Linkedin令牌.它必须转到使用Firebase管理员用户生成令牌的Web服务.
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.
这篇关于使用自定义令牌(ERROR_INVALID_CUSTOM_TOKEN)的LinkedIn登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!