首先我们获取到的token是一个二进制文件,但是打印的时候只是显示他的字节,如下图

然后就揪心了,网上收罗了大神的方法,可能是因为太简单,没人愿意留下在博客里,这种事还是我自己来吧,主要还是自己以后用的时候方便找

1.重新实例化token

 let nsdataStr = NSData.init(data: credentials.token)

2.将token转换成字符串

let datastr = nsdataStr.description.replacingOccurrences(of: "<", with: "").replacingOccurrences(of: ">", with: "").replacingOccurrences(of: " ", with: "")

3.打印

print(datastr)

打印结果就是你想看到的字符串了吧