? AFHTTPRequestOperationManager *_manager;
?[_manager.requestSerializer setValue: [NSString stringWithFormat:@"Bearer %@", token] forHTTPHeaderField:@"Authorization"];
//固定字段尤溜,Bearer字段后有個(gè)空格
最近項(xiàng)目中的token過期問題處理大概的思路:
1.登錄接口獲取token审姓;
2.請(qǐng)求數(shù)據(jù)時(shí)税手,后臺(tái)校驗(yàn)token是否過期泪电,不過期返回正常數(shù)據(jù)胁附;if過期怀浆,刷新token涧至,if刷新token失敗,重新通過登錄接口獲取token纱皆,獲取到新的token再次請(qǐng)求數(shù)據(jù)
以此循環(huán)就可以正常run