要运行示例项目,首先将仓库进行克隆,然后从 Example 目录中运行 pod install
。
导入
#import "BAHYouTubeOAuth.h"
无论用户登录何处YouTube并检索令牌
BAHYouTubeOAuth *youTubeOAuth = [[BAHYouTubeOAuth alloc]init];
[youTubeOAuth authenticateWithYouTubeUsingYouTubeClientID:youTubeClientID
youTubeClientSecret:youTubeClientSecret
responseType:response_type
scope:scope
state:state
appURLCallBack:redirectURI
accessType:access_type
viewController:self
:^(BOOL success, NSString *youTubeToken, NSString *youTubeRefreshToken) {
if (success) {
//the token you will use to request right now
[[NSUserDefaults standardUserDefaults] setObject:youTubeToken forKey:@"youtube_token"];
//token you can use to request a new token on your behalf for requestion later
//this only shows when you ask for "offline access"
[[NSUserDefaults standardUserDefaults] setObject:youTubeRefreshToken forKey:@"youtube_refresh"];
[[NSUserDefaults standardUserDefaults] synchronize];
//Do whatever you need with the token
}
}];
BHughes3388, [email protected]
BAHYouTubeOAuth 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。