我试图获得Facebook Accesstoken。当我打印accessToken时,它返回一个带有appId和authenticationToken的对象,如何解析令牌? 我使用以下代码:
let loginManager = LoginManager()
loginManager.logIn([ .publicProfile, .userFriends, .email ], viewController: self) { loginResult in
switch loginResult {
case .failed(let error):
print(error)
case .cancelled:
print("User cancelled login.")
case .success(let grantedPermissions, let declinedPermissions, let accessToken):
print("accessToken: " + String(describing: accessToken))
break
}
}
答案 0 :(得分:3)
您尝试解析的令牌是结构
实际标记为:
accessToken.authenticationToken
你的代码应该是这样的:
let loginManager = LoginManager()
loginManager.logIn([ .publicProfile, .userFriends, .email ], viewController: self) { loginResult in
switch loginResult {
case .failed(let error):
print(error)
case .cancelled:
print("User cancelled login.")
case .success(let grantedPermissions, let declinedPermissions, let accessToken):
print("accessToken: " + accessToken.authenticationToken)
break
}
}