基于 Swift 的 OAuth 的 iOS 庫:OAuthSwift

jopen 10年前發布 | 22K 次閱讀 Apple Swift開發 OAuthSwift

OAuthSwift 是基于 Swift 的 OAuth 的 iOS 庫,支持 OAuth 1 和 OAuth 2。

OAuth 頁面

推ter
Flickr
Github
Instagram
Foursquare
Fitbit
Withings

示例

// OAuth1.0
let oauthswift = OAuth1Swift(
    consumerKey:    "********",
    consumerSecret: "********",
    requestTokenUrl: "https://api.推ter.com/oauth/request_token",
    authorizeUrl:    "https://api.推ter.com/oauth/authorize",
    accessTokenUrl:  "https://api.推ter.com/oauth/access_token"
)
oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/推ter"), success: {
    credential, response in
    println(credential.oauth_token)
    println(credential.oauth_token_secret)
}, failure: failureHandler)

// OAuth2.0
let oauthswift = OAuth2Swift(
    consumerKey:    "********",
    consumerSecret: "********",
    authorizeUrl:   "https://api.instagram.com/oauth/authorize",
    responseType:   "token"
)
oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/instagram"), scope: "likes+comments", state:"INSTAGRAM", success: {
    credential, response in
    println(credential.oauth_token)
}, failure: failureHandler)

Setting Swift Compiler

基于 Swift 的 OAuth 的 iOS 庫:OAuthSwift

Setting URL Schemes

基于 Swift 的 OAuth 的 iOS 庫:OAuthSwift

Images

基于 Swift 的 OAuth 的 iOS 庫:OAuthSwift基于 Swift 的 OAuth 的 iOS 庫:OAuthSwift基于 Swift 的 OAuth 的 iOS 庫:OAuthSwift

 

項目主頁:http://www.baiduhome.net/lib/view/home/1416041629789

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!