Code Monkey home page Code Monkey logo

oauthswift's Introduction

OAuthSwift

OAuthSwift

Swift based OAuth library for iOS and macOS.

Support OAuth1.0, OAuth2.0

Twitter, Flickr, Github, Instagram, Foursquare, Fitbit, Withings, Linkedin, Dropbox, Dribbble, Salesforce, BitBucket, GoogleDrive, Smugmug, Intuit, Zaim, Tumblr, Slack, Uber, Gitter, Facebook, Spotify, Typetalk, SoundCloud, Twitch, Reddit, etc

Installation

OAuthSwift is packaged as a Swift framework. Currently this is the simplest way to add it to your app:

  • Drag OAuthSwift.xcodeproj to your project in the Project Navigator.
  • Select your project and then your app target. Open the Build Phases panel.
  • Expand the Target Dependencies group, and add OAuthSwift framework.
  • import OAuthSwift whenever you want to use OAuthSwift.

Support Carthage

github "OAuthSwift/OAuthSwift" ~> 2.2.0
  • Run carthage update.
  • On your application targets’ “General” settings tab, in the “Embedded Binaries” section, drag and drop OAuthSwift.framework from the Carthage/Build/iOS folder on disk.

Support CocoaPods

  • Podfile
platform :ios, '10.0'
use_frameworks!

pod 'OAuthSwift', '~> 2.2.0'

Swift Package Manager Support

import PackageDescription

let package = Package(
    name: "MyApp",
    dependencies: [
        .package(name: "OAuthSwift",
            url: "https://github.com/OAuthSwift/OAuthSwift.git",
            .upToNextMajor(from: "2.2.0"))
    ]
)

Old versions

Swift 3

Use the swift3 branch, or the tag 1.1.2 on main branch

Swift 4

Use the tag 1.2.0 on main branch

Objective-C

Use the tag 1.4.1 on main branch

How to

Setting URL Schemes

In info tab of your target Image Replace oauth-swift by your application name

Handle URL in AppDelegate

  • On iOS implement UIApplicationDelegate method
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey  : Any] = [:]) -> Bool {
  if url.host == "oauth-callback" {
    OAuthSwift.handle(url: url)
  }
  return true
}
  • On iOS 13, UIKit will notify UISceneDelegate instead of UIApplicationDelegate.
  • Implement UISceneDelegate method
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        guard let url = URLContexts.first?.url else {
            return
        }
        if url.host == "oauth-callback" {
            OAuthSwift.handle(url: url)
        }
}

⚠️ Any other application may try to open a URL with your url scheme. So you can check the source application, for instance for safari controller :

if options[.sourceApplication] as? String == "com.apple.SafariViewService" {
  • On macOS you must register a handler on NSAppleEventManager for event type kAEGetURL (see demo code)
func applicationDidFinishLaunching(_ aNotification: NSNotification) {
    NSAppleEventManager.shared().setEventHandler(self, andSelector:#selector(AppDelegate.handleGetURL(event:withReplyEvent:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
}
func handleGetURL(event: NSAppleEventDescriptor!, withReplyEvent: NSAppleEventDescriptor!) {
    if let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue, let url = URL(string: urlString) {
        OAuthSwift.handle(url: url)
    }
}

Authorize with OAuth1.0

// create an instance and retain it
oauthswift = OAuth1Swift(
    consumerKey:    "********",
    consumerSecret: "********",
    requestTokenUrl: "https://api.twitter.com/oauth/request_token",
    authorizeUrl:    "https://api.twitter.com/oauth/authorize",
    accessTokenUrl:  "https://api.twitter.com/oauth/access_token"
)
// authorize
let handle = oauthswift.authorize(
    withCallbackURL: "oauth-swift://oauth-callback/twitter") { result in
    switch result {
    case .success(let (credential, response, parameters)):
      print(credential.oauthToken)
      print(credential.oauthTokenSecret)
      print(parameters["user_id"])
      // Do your request
    case .failure(let error):
      print(error.localizedDescription)
    }             
}

OAuth1 without authorization

No urls to specify here

// create an instance and retain it
oauthswift = OAuth1Swift(
    consumerKey:    "********",
    consumerSecret: "********"
)
// do your HTTP request without authorize
oauthswift.client.get("https://api.example.com/foo/bar") { result in
    switch result {
    case .success(let response):
        //....
    case .failure(let error):
        //...
    }
}

Authorize with OAuth2.0

// create an instance and retain it
oauthswift = OAuth2Swift(
    consumerKey:    "********",
    consumerSecret: "********",
    authorizeUrl:   "https://api.instagram.com/oauth/authorize",
    responseType:   "token"
)
let handle = oauthswift.authorize(
    withCallbackURL: "oauth-swift://oauth-callback/instagram",
    scope: "likes+comments", state:"INSTAGRAM") { result in
    switch result {
    case .success(let (credential, response, parameters)):
      print(credential.oauthToken)
      // Do your request
    case .failure(let error):
      print(error.localizedDescription)
    }
}

Authorize with OAuth2.0 and proof key flow (PKCE)

// create an instance and retain it
oauthswift = OAuth2Swift(
    consumerKey:    "********",
    consumerSecret: "********",
    authorizeUrl: "https://server.com/oauth/authorize",
    responseType: "code"
)
oauthswift.accessTokenBasicAuthentification = true

guard let codeVerifier = generateCodeVerifier() else {return}
guard let codeChallenge = generateCodeChallenge(codeVerifier: codeVerifier) else {return}

let handle = oauthswift.authorize(
    withCallbackURL: "myApp://callback/",
    scope: "requestedScope", 
    state:"State01",
    codeChallenge: codeChallenge,
    codeChallengeMethod: "S256",
    codeVerifier: codeVerifier) { result in
    switch result {
    case .success(let (credential, response, parameters)):
      print(credential.oauthToken)
      // Do your request
    case .failure(let error):
      print(error.localizedDescription)
    }
}

See demo for more examples

Handle authorize URL

The authorize URL allows the user to connect to a provider and give access to your application.

By default this URL is opened into the external web browser (ie. safari), but apple does not allow it for app-store iOS applications.

To change this behavior you must set an OAuthSwiftURLHandlerType, simple protocol to handle an URL

oauthswift.authorizeURLHandler = ..

For instance you can embed a web view into your application by providing a controller that displays a web view (UIWebView, WKWebView). Then this controller must implement OAuthSwiftURLHandlerType to load the URL into the web view

func handle(_ url: NSURL) {
  let req = URLRequest(URL: targetURL)
  self.webView.loadRequest(req)
  ...

and present the view (present(viewController, performSegue(withIdentifier: , ...) You can extend OAuthWebViewController for a default implementation of view presentation and dismiss

Use the SFSafariViewController (iOS9)

A default implementation of OAuthSwiftURLHandlerType is provided using the SFSafariViewController, with automatic view dismiss.

oauthswift.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oauthswift)

Of course you can create your own class or customize the controller by setting the variable SafariURLHandler#factory.

Make signed request

Just call HTTP functions of oauthswift.client

oauthswift.client.get("https://api.linkedin.com/v1/people/~") { result in
    switch result {
    case .success(let response):
        let dataString = response.string
        print(dataString)
    case .failure(let error):
        print(error)
    }
}
// same with request method
oauthswift.client.request("https://api.linkedin.com/v1/people/~", .GET,
      parameters: [:], headers: [:],
      completionHandler: { ...

See more examples in the demo application: ViewController.swift

OAuth provider pages

Images

Image Image Image

Contributing

See CONTRIBUTING.md

Add a new service in demo app

Integration

OAuthSwift could be used with others frameworks

You can sign Alamofire request with OAuthSwiftAlamofire

To achieve great asynchronous code you can use one of these integration frameworks

License

OAuthSwift is available under the MIT license. See the LICENSE file for more info.

License Platform Language Cocoapod Carthage compatible Build Status

oauthswift's People

Contributors

alex-taffe avatar almostintuitive avatar antondevs avatar aranasaurus avatar automatt avatar bjoebrunn avatar corinnekrych avatar deyton avatar dongri avatar dparne avatar e-marchand avatar iby avatar jrtibbetts avatar khoogheem avatar ktakayama avatar mattfaluotico avatar maxdesiatov avatar mikemtol avatar mrwowander avatar nrivard avatar phatblat avatar phimage avatar ruipfcosta avatar rvangraan avatar s-aska avatar shrutic avatar slizeray avatar svoip avatar tkawaji avatar wesley-dynamicowl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oauthswift's Issues

Crash when user denies access.

When user denies access by taping a cancel button present at the provider, there is a oauth_problem parameter sent instead of oauth_token & oauth_verifier.
Fix : #10

Library not loaded

When I run the following code in the emulator on a virtual device it runs without a problem, but when I run it on a real iPhone 6 it gives me the following error. Anyone that has a solution for this problem? I run currently (Xcode 6.2 with branche OAuthSwift-ad0f2ecca892e3bd309f09eeb8f591036faebacb) so that's not swift 1.2.

dyld: Library not loaded: @rpath/OAuthSwift.framework/OAuthSwift
  Referenced from: /private/var/mobile/Containers/Bundle/Application/4491E67B-580A-430F-84F3-E571CCD1B184/LinkingSkills.app/LinkingSkills
  Reason: image not found
(lldb) 
import UIKit
import OAuthSwift

class LinkedinLoginViewController: UIViewController, NSXMLParserDelegate {
    let dataString = NSString();
    var parser = NSXMLParser()
    var posts = NSMutableArray()
    var elements = NSMutableDictionary()
    var element = NSString()

    var voornaam = NSMutableString()
    var achternaam = NSMutableString()
    var skills = NSMutableArray()


    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

oauth_token in request?

Under the OAuthSwiftClient, authorizationHeaderForMethod function, the authorisation parameters do not include oauth_token when I try to do a request. I tested it out, and oauth_token is an empty string, so it's not being included. I think this is why my request is not working -- can anybody tell me how to include the oauth_token into the request?

I'm initialising the OAuth1Swift class in my main View Controller. Therefore I don't think I can get the oauth_token until I initialise it, which is not happening before the authorizationHeaderForMethod, so I don't get a value. Any ideas?

Serious compile issues

The error is: unknown>:0: error: could not build Objective-C module 'OAuthSwift'
It works and suddenly it gives this error on build. I have tried this on 3 different laptops and the solution to clean build and delete derived data does not work all the time. Sometimes it shows one error(aforementioned) or it shows 21 errors
We spent over 4 hours with apple engineers on this in a hackathon with no progress.
Thank you for your work!

Get login info from Callback?

How could I get the employee's unique ID from them logging in to the app connect page in Quickbooks? In other words, how can I access the callback's parameters sent back by Quickbooks so I can use that for other tasks?

Is it posible to make a put request ?

Thank you for this great library! I was wondering if there is a way to make a PUT request?
oauthswift.client.get() and oauthswift.client.post() work just fine but I dont see the put method.

Uber Authentication failed "HTTP Status 401: Unauthorized, Response: {"error": "invalid_client"}"

i am using this library for Uber Authetication
https://developer.uber.com/v1/auth/

I have done like this

func doOAuthUber(){

    let oauthswift = OAuth2Swift(
        consumerKey:    "fXfXXXXXXXUo9vtKzobXXXXXUDO",
        consumerSecret: "e5XXXXXXXq2w63qz9szEx7uXXXXXXo03W",
        authorizeUrl:   "https://login.uber.com/oauth/authorize",
        accessTokenUrl: "https://login.uber.com/oauth/token",
        responseType:   "code"
    )

    var originalString = "jamesappv2://oauth/callback"
    var encodedCallBackUrl = originalString.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())

    println("encodedCallBackUrl: \(encodedCallBackUrl)")


    let state: String = ""
    oauthswift.authorizeWithCallbackURL( NSURL(string: encodedCallBackUrl!)!, scope: "request%20history", state: state, success: {
        credential, response in

        println(credential.oauth_token)
        self.personalDriverLoader.stopAnimating()



        }, failure: {(error:NSError!) -> Void in

            self.personalDriverLoader.stopAnimating()
            println(error.localizedDescription)
    })


}

but getting this response
HTTP Status 401: Unauthorized, Response: {"error": "invalid_client"}

I have triple checked that my client_id (consumerKey) and secret (consumerSecret) are correct.
What I have done wrong here

Please help

Help getting instagram profile data

How can i get the users's profile data ? Username, id , etc..

In instagram theres no end like /user/me .

Instagram sends the profile info in the authentication process

401

I'm using the same link and I tried to access it from POSTMAN and it worked so I tried it in mobile but it ended up return 401 http error. Is there anything i missed out?

screen shot 2015-05-08 at 7 44 14 am

func doOAuthTwitter(){
    let oauthswift = OAuth1Swift(
        consumerKey:    Twitter["consumerKey"]!,
        consumerSecret: Twitter["consumerSecret"]!,
        requestTokenUrl: "https://api.twitter.com/oauth/request_token",
        authorizeUrl:    "https://api.twitter.com/oauth/authorize",
        accessTokenUrl:  "https://api.twitter.com/oauth/access_token"
    )

    //oauthswift.webViewController = WebViewController()
    oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/twitter")!, success: {
        credential, response in
        self.showAlertView("Twitter", message: "auth_token:\(credential.oauth_token)\n\noauth_toke_secret:\(credential.oauth_token_secret)")
        var parameters =  Dictionary<String, AnyObject>()
        oauthswift.client.get("https://api.twitter.com/1.1/account/verify_credentials.json?skip_status=true&include_email=true", parameters: parameters,
            success: {
                data, response in
                let jsonDict: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil)
                println(jsonDict)
            }, failure: {(error:NSError!) -> Void in
                println(error)
            })

        }, failure: {(error:NSError!) -> Void in
            println(error.localizedDescription)
        }
    )
}

Suggested method of installing framework

What's the suggested way of installing this Framework? If you just drag and drop files in the SourceKitService crashes continuously

Edit: The demo project crashes sourcekit as well

Authorisation not completing?

I was using the library fine yesterday, but today the callback authorisation is not working. I've tracked the problem down to one area (using many println()s) and this is it:

screen shot 2015-04-10 at 5 39 52 pm

"Here - 1" prints fine -- the problem is "Here - 2". This means the Notification Center is the problem. Has anyone else experienced this problem, and has anybody found the way to fix this?

JSON Response support

I modified the postOAuthAccessTokenWithRequestTokenByCode method to support JSON responses like Dribbble OAuth implementation

func postOAuthAccessTokenWithRequestTokenByCode(code: String, success: TokenSuccessHandler, failure: FailureHandler?) {
        var parameters = Dictionary<String, AnyObject>()
        parameters["client_id"] = self.consumer_key
        parameters["client_secret"] = self.consumer_secret
        parameters["code"] = code
        parameters["grant_type"] = "authorization_code"

        self.client.post(self.access_token_url!, parameters: parameters, success: {
            data, response in
            let responseString = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil)
            if let parameters:NSDictionary = responseString as? NSDictionary{
                self.client.credential.oauth_token = parameters["access_token"] as String
                success(credential: self.client.credential, response: response)
            }
        }, failure: failure)
    }

I was wondering if you had any ideas on how to integrate this gracefully into the project so the other "normal string" response types is supported as well.

Carthage update fails

I made the cartfile, but when I did carthage update it fails. Help? Thanks!

*** Fetching OAuthSwift
*** Checking out OAuthSwift at "v0.3.2"
*** xcodebuild output can be found in /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/carthage-xcodebuild.ItCH7l.log
*** Building scheme "OAuthSwift" in OAuthSwift.xcodeproj
2015-03-13 15:33:31.829 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77
Details: Failed to load dependencies output contents from /var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuth1Swift.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “OAuth1Swift.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e55af210 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuth1Swift.d, NSUnderlyingError=0x7fd8e5591ea0 "The operation couldn’t be completed. No such file or directory"}. User info: { NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuth1Swift.d"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; }. Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong)) Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. 2015-03-13 15:33:31.847 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77 Details: Failed to load dependencies output contents from/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuth2Swift.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “OAuth2Swift.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e354b090 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuth2Swift.d, NSUnderlyingError=0x7fd8e3562a70 "The operation couldn’t be completed. No such file or directory"}. User info: {
NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuth2Swift.d";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn\U2019t be completed. No such file or directory"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString ___strong, void (^__strong)(NSString *__strong))
Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2015-03-13 15:33:31.863 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77
Details: Failed to load dependencies output contents from /var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/String+OAuthSwift.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “String+OAuthSwift.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e372aaf0 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/String+OAuthSwift.d, NSUnderlyingError=0x7fd8e3715c10 "The operation couldn’t be completed. No such file or directory"}. User info: { NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/String+OAuthSwift.d"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; }. Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong)) Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. 2015-03-13 15:33:31.879 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77 Details: Failed to load dependencies output contents from/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftClient.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “OAuthSwiftClient.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e37299f0 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftClient.d, NSUnderlyingError=0x7fd8e372eef0 "The operation couldn’t be completed. No such file or directory"}. User info: {
NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftClient.d";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn\U2019t be completed. No such file or directory"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong))
Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2015-03-13 15:33:31.895 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77
Details: Failed to load dependencies output contents from /var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftCredential.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “OAuthSwiftCredential.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e56435c0 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftCredential.d, NSUnderlyingError=0x7fd8e3552b30 "The operation couldn’t be completed. No such file or directory"}. User info: { NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftCredential.d"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; }. Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong)) Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. 2015-03-13 15:33:31.911 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77 Details: Failed to load dependencies output contents from/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Utils.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “Utils.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e57679e0 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Utils.d, NSUnderlyingError=0x7fd8e5767ae0 "The operation couldn’t be completed. No such file or directory"}. User info: {
NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Utils.d";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn\U2019t be completed. No such file or directory"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong))
Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2015-03-13 15:33:31.928 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77
Details: Failed to load dependencies output contents from /var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/SHA1.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “SHA1.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e3553740 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/SHA1.d, NSUnderlyingError=0x7fd8e56a48c0 "The operation couldn’t be completed. No such file or directory"}. User info: { NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/SHA1.d"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; }. Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong)) Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. 2015-03-13 15:33:31.946 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77 Details: Failed to load dependencies output contents from/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/NSURL+OAuthSwift.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “NSURL+OAuthSwift.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e5700040 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/NSURL+OAuthSwift.d, NSUnderlyingError=0x7fd8e3553390 "The operation couldn’t be completed. No such file or directory"}. User info: {
NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/NSURL+OAuthSwift.d";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn\U2019t be completed. No such file or directory"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong))
Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2015-03-13 15:33:31.962 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77
Details: Failed to load dependencies output contents from /var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftHTTPRequest.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “OAuthSwiftHTTPRequest.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e3723090 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftHTTPRequest.d, NSUnderlyingError=0x7fd8e3565f80 "The operation couldn’t be completed. No such file or directory"}. User info: { NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthSwiftHTTPRequest.d"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; }. Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong)) Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. 2015-03-13 15:33:31.981 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77 Details: Failed to load dependencies output contents from/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Int+OAuthSwift.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “Int+OAuthSwift.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e35684b0 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Int+OAuthSwift.d, NSUnderlyingError=0x7fd8e566c780 "The operation couldn’t be completed. No such file or directory"}. User info: {
NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Int+OAuthSwift.d";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn\U2019t be completed. No such file or directory"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong))
Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2015-03-13 15:33:31.997 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77
Details: Failed to load dependencies output contents from /var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Dictionary+OAuthSwift.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “Dictionary+OAuthSwift.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e37508e0 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Dictionary+OAuthSwift.d, NSUnderlyingError=0x7fd8e3718c30 "The operation couldn’t be completed. No such file or directory"}. User info: { NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/Dictionary+OAuthSwift.d"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; }. Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong)) Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. 2015-03-13 15:33:32.014 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77 Details: Failed to load dependencies output contents from/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/NSData+OAuthSwift.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “NSData+OAuthSwift.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e3568660 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/NSData+OAuthSwift.d, NSUnderlyingError=0x7fd8e372d260 "The operation couldn’t be completed. No such file or directory"}. User info: {
NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/NSData+OAuthSwift.d";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn\U2019t be completed. No such file or directory"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong))
Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2015-03-13 15:33:32.031 xcodebuild[7699:57000] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77
Details: Failed to load dependencies output contents from ``/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthWebViewController.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “OAuthWebViewController.d” couldn’t be opened because there is no such file." UserInfo=0x7fd8e3751330 {NSFilePath=/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthWebViewController.d, NSUnderlyingError=0x7fd8e35684f0 "The operation couldn’t be completed. No such file or directory"}. User info: {
NSFilePath = "/var/root/Library/Developer/Xcode/DerivedData/OAuthSwift-agmslwgnqnyoymdyahotljlieful/Build/Intermediates/OAuthSwift.build/Release-iphonesimulator/OAuthSwift.build/Objects-normal/i386/OAuthWebViewController.d";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn\U2019t be completed. No such file or directory"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *_strong))
Thread: <NSThread: 0x7fd8e5590fe0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
*
BUILD FAILED **

The following build commands failed:
CompileSwift normal i386 /Users/laralu/Documents/cart/Carthage/Checkouts/OAuthSwift/OAuthSwift/OAuth1Swift.swift
CompileSwift normal i386 /Users/laralu/Documents/cart/Carthage/Checkouts/OAuthSwift/OAuthSwift/OAuth2Swift.swift
CompileSwift normal i386 /Users/laralu/Documents/cart/Carthage/Checkouts/OAuthSwift/OAuthSwift/String+OAuthSwift.swift
CompileSwiftSources normal i386 com.apple.xcode.tools.swift.compiler
(4 failures)

Google Drive localhost support!!

Register new client as Type: Others, under Installed App Category @ google developer console

oauthswift.webViewController = WebViewController()

// register callbackURL similar to http://localhost/google with 
oauthswift.authorizeWithCallbackURL(...)

// In webview controller delegate method "shouldStartLoadWithRequest" check like below
if (request.URL.scheme == "oauth-swift" || request.URL.host == "localhost" ) {
            self.dismissViewControllerAnimated(true, completion: nil)

            if(request.URL.host == "localhost") {
                OAuth2Swift.handleOpenURL(request.URL)
            }
        }

Callback URL

Hi everyone
When I set the callback URL to my own application it gives error
Error Domain=NSURLErrorDomain Code=400 "HTTP Status 400: Bad Request, Response: oauth_problem=parameter_rejected&message=oauth_callback" UserInfo=0x7c8b4e80
But when I set the callback url to my website it works.
And another issue is that I cannot handle the access token and access token secret, I can only see it in a url attached such as "http://website.com?access_token=sdjflkdjsf&access_token_secret=asdasdasd"

func Authenthication(){
        let client = OAuth1Swift(
            consumerKey: "consumerkey",
            consumerSecret: "consumersecret",
            requestTokenUrl: "http://192.168.54.35/ergasia/oauth/initiate",
            authorizeUrl: "http://192.168.54.35/ergasia/oauth/authorize",
            accessTokenUrl: "http://192.168.54.35/ergasia/oauth/token")
        client.webViewController = WebViewController()
        client.authorizeWithCallbackURL(NSURL(string: "nettium://")!, success: { credential, response in
            println("\(credential.oauth_token)")
            self.credent = credential
        }) { (error) -> Void in
            println(error)
        }
    }

If I do in this way everything works, except it does not show an alertView and cannot get an access token

        client.authorizeWithCallbackURL(NSURL(string: "http://192.168.54.35/ergasia/customer/account")!, success: { credential, response in
            self.showAlertView("Magento", message: "auth_token:\(credential.oauth_token)\n\noauth_toke_secret:\(credential.oauth_token_secret)")
            println("\(credential.oauth_token)")
        }) { (error) -> Void in
            println(error)
        }

Any ideas? Need help, thanks

OAuth1 signature error (HMAC & SHA1)

I manually included all files in my project target for iOS 7, and when I try to log into linkedin I got a Signature Invalid exception. After debugging The base string is correct but the signature generated is wrong.

OAuthSwift implemented its own HMAC and SHA1 algorithms, so I don't see I have to include any additional crypto libraries.

Am I missing any project settings or libraries/frameworks.

Custom oauth2 access

Hello,
I am trying a custom oauth2 access and I am new to swift.

I am following instruction from https://django-oauth-toolkit.readthedocs.org/en/0.3.2/tutorial/rest_framework_integration.html.

The authorization process is
Use initial username and password to get a token
Use the token to perform further api calls.

In my case, there is only accessTokenUrl and authorizeUrl is not applicable. Wondering how to proceed further.
Appreciate any inputs.

  • S

    func doOAuthScreener(){

      let oauthswift = OAuth2Swift(
    
          //https://django-oauth-toolkit.readthedocs.org/en/latest/rest-framework/getting_started.html
    
          consumerKey:    Screener["consumerKey"]!,
    
          consumerSecret: Screener["consumerSecret"]!,
    
          authorizeUrl:   HERE, 
    
          accessTokenUrl: HERE, // This seem to be http://localhost:8000/o/token/
    
          responseType:   "code"
    
      )
    
    
    
    
    
      let state: String = generateStateWithLength(20) as String
    
    
    
    
    
      oauthswift.authorizeWithCallbackURL( NSURL(string: "HERE")!, scope: "user,repo", state: state, success: {
    
          credential, response, parameters in
    
          self.showAlertView("Screener", message: "oauth_token:\(credential.oauth_token)")
    
          }, failure: {(error:NSError!) -> Void in
    
              println(error.localizedDescription)
    
      })    
    

    }

API Tokens are Visible

It's cool to see the project working instantly, but your keys should be removed from OAuthSwiftDemo's ViewController.swift file.

A readme in that folder guiding users on how to create their own would be a better solution.

Yelp example

Is there any way to add an example for how this can be used for Yelp? Seems that their API is different from others because the token is already provided and therefore there is not an endpoint available to retrieve the token. I'm hoping there is a way with your framework to manually provide the token?

oAuth 1.0a

Hi,

Good job mon with this project, just one doubt, does this work with oauth 1.0a? I have an API where I have the Consumer Key and Secret also Token and Token Secret but any time I am trying to get something I am receiving a INVALID_SIGNATURE.

Best

Error: Instagram: Redirect URI does not match registered URI

Damn close! Love to wrap this up. It's been a journey into the land of OAuth! :-)

Ok, i'm getting this error. Not sure what the correct URI is for the re/direct, entered my web site address, that would too easy right? Ideas most appreciated. thanks
ig1

ig2

Example of one API call for each service

Hey @dongri. Awesome job making this example!
Can you include an example of one api call for each service?
e.g.

oauthswift.client.get("http://api.linkedin.com/v1/people/~?", parameters: parameters, success: { (data, response) -> Void in
            println("Succes") // or print some data from the profile
            }, failure: { (error) -> Void in
                println("Failed") // or reason what failed
        })

When I do the above for linkedIn I am getting Failure in the following function:

    func doOAuthLinkedin(){
        let oauthswift = OAuth1Swift(
            consumerKey:    Linkedin["consumerKey"]!,
            consumerSecret: Linkedin["consumerSecret"]!,
            requestTokenUrl: "https://api.linkedin.com/uas/oauth/requestToken",
            authorizeUrl:    "https://api.linkedin.com/uas/oauth/authenticate",
            accessTokenUrl:  "https://api.linkedin.com/uas/oauth/accessToken"
        )
        oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/linkedin")!, success: {
            credential, response in
            print("\n client oauth_token - " + credential.oauth_token)
            print("\n client oauth_token_secret - " + credential.oauth_token_secret)
            print("\n client consumer_key - " + credential.consumer_key)
            print("\n client consumer_secret - " + credential.consumer_secret)
            print("\n client oauth_verifier - " + credential.oauth_verifier)

        var parameters =  Dictionary<String, AnyObject>()
        parameters["oauth_nonce"] = "1234"
        oauthswift.client.get("http://api.linkedin.com/v1/people/~?", parameters: parameters, success: { (data, response) -> Void in
            println("Success")
            }, failure: { (error) -> Void in
                println("Failed")
        })
        self.performSegueWithIdentifier("jumpToUserTable", sender: self)

    }

Installation issue

As suggested by the documentation, I did,

Drag OAuthSwift.xcodeproj to my project in the Project Navigator.
Selected my project and then my app target. Open the Build Phases panel.
Expand the Target Dependencies group, and add OAuthSwift framework.

and Build Failed, with no any error messages. please help

Swift 1.2

When do you expect an update to be compatible with Swift 1.2?

I get an error saying that "the module was compiled using an older version of the compiler".

I installed via Carthage.

Keep user logged

Hi,
suppose that I have an app with a Twitter login button. After the login, I'm given back the credentials and I can store them in NSUserDefaults.standardUserDefaults()
If the user runs the app again, and I see that he has auth credentials already set, how can I set up the oauth client so that it uses them without requiring the login again?

Also, once the user it logged in, how to get info of the logged user, such is user id etc?

Thanks

<unknown>:0: error: could not build Objective-C module 'OAuthSwift'

Getting an error on compile - didn't get the error the first time around, but getting it now - Can't find what's differing between that and the demo app..

Here's the error:

CompileSwift normal x86_64 /Users/danielarcher/XCode/Whistle/Whistle/ViewController.swift
    cd /Users/danielarcher/XCode/Whistle
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/danielarcher/XCode/Whistle/Whistle/ViewController.swift /Users/danielarcher/XCode/Whistle/Whistle/AppDelegate.swift /Users/danielarcher/XCode/Whistle/Whistle/Constants.swift -target x86_64-apple-ios8.1 -target-cpu core2 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -I /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Products/Debug-iphonesimulator -F /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Products/Debug-iphonesimulator -F /Users/danielarcher/XCode/Whistle/Carthage/Build/iOS -g -module-cache-path /Users/danielarcher/Library/Developer/Xcode/DerivedData/ModuleCache -Xcc -I/Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Whistle-generated-files.hmap -Xcc -I/Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Whistle-own-target-headers.hmap -Xcc -I/Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Whistle-all-target-headers.hmap -Xcc -iquote -Xcc /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Whistle-project-headers.hmap -Xcc -I/Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Products/Debug-iphonesimulator/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/DerivedSources/x86_64 -Xcc -I/Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Objects-normal/x86_64/ViewController~partial.swiftdoc -Onone -module-name Whistle -emit-module-path /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Objects-normal/x86_64/ViewController~partial.swiftmodule -serialize-diagnostics-path /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Objects-normal/x86_64/ViewController.dia -emit-dependencies-path /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Objects-normal/x86_64/ViewController.d -o /Users/danielarcher/Library/Developer/Xcode/DerivedData/Whistle-aabmrwgbetwsozfyrtwlpnvcnaxk/Build/Intermediates/Whistle.build/Debug-iphonesimulator/Whistle.build/Objects-normal/x86_64/ViewController.o

Modify webview

Guys, i know this is probably a lame question, but.. How can i modify de webview ? In my app i have everyrhing under a navigation crontoller, when login in with the oauthswift , i get ro this plain blank uiviewcontroller in blank, it takes the whole screen .. I get instagram textfields and interface almost overlapoing the status bar. I would like to get that webview viewconteoller inside of my navigstion controller etc

OAuthSwiftClient fix

In OAuthSwiftClient.swift class:

in request function if the url contains latin chars, NSURL crashes. I fix and paste below

func request(url: String, method: String, parameters: Dictionary<String, AnyObject>, success: OAuthSwiftHTTPRequest.SuccessHandler?, failure: OAuthSwiftHTTPRequest.FailureHandler?) {
    if let url = NSURL(string: url.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)
    {
        let request = OAuthSwiftHTTPRequest(URL: url, method: method, parameters: parameters)
        if self.credential.oauth2 {
            request.headers = ["Authorization": "Bearer \(self.credential.oauth_token)"]
        } else {
            request.headers = ["Authorization": OAuthSwiftClient.authorizationHeaderForMethod(method, url: url, parameters: parameters, credential: self.credential)]
        }
        request.successHandler = success
        request.failureHandler = failure
        request.dataEncoding = dataEncoding
        request.encodeParameters = true
        request.start()
    }
}

thanks for the library,
it rocks

How to send custom POST request

I want to send my custom post request using your library. here is my code
Please help, how can I send my request using this library

    func callRequestAPI(url:String){

    var request = NSMutableURLRequest(URL: NSURL(string: url)!)
    var session = NSURLSession.sharedSession()
    request.HTTPMethod = "POST"

    var params:[String: AnyObject] = [
        "product_id" : selectedUberProductId,
        "start_latitude" : start_lat,
        "start_longitude" : start_lng,
        "end_latitude" : end_lat,
        "end_longitude" : end_lng]

     request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")

    var err: NSError?
    request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: NSJSONWritingOptions.allZeros, error: &err)

            let task = session.dataTaskWithRequest(request) {
                data, response, error in

                if let httpResponse = response as? NSHTTPURLResponse {
                    if httpResponse.statusCode != 202 {
                        println("response was not 202: \(response)")

                        return
                    }
                }
                if (error != nil) {
                    println("error submitting request: \(error)")
                    return
                }

                // handle the data of the successful response here
                var result = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.allZeros, error: nil) as! NSDictionary


                println(result)

                if let request_id: String = result["request_id"] as? String{

                    println(request_id)
                }

                if let driver: String = result["driver"] as? String{

                    println(driver)
                }

                if let eta: Int = result["eta"] as? Int{

                    println(eta)
                }

                if let location: String = result["location"] as? String{

                    println(location)
                }


                if let status: String = result["status"] as? String{

                    println(status)
                }


                if let surge_multiplier: Int = result["surge_multiplier"] as? Int{

                    println(surge_multiplier)
                }

                if let vehicle: String = result["vehicle"] as? String{

                    println(vehicle)
                }

            }

            task.resume()

     }

POST request Authentication Failed

I am trying to upload a piece of data to Intuit's Quickbooks API, by doing something like this:

//Set parameters for request
        let parameters: [String: AnyObject] = [
            "NameOf":"Employee",
            "EmployeeRef":[
                "value":"64"
            ],
            "CustomerRef":[
                "value":"21"
            ],
            "ItemRef":[
                "value":"1"
            ],
            "BreakHours": 1,
            "BreakMinutes":0,
            "StartTime": "example start time",
            "EndTime": "example end time",
            "Description": "example description",
            "domain": "QBO",
            "sparse": false
        ]
        //Send a POST request to the Quickbooks API endpoint
        oauthswift.client.post("https://sandbox-quickbooks.api.intuit.com/v3/company/<companyID>/timeactivity", parameters:  parameters, success: {
            data, response in
            println("success")
            }, failure: {
            error in
            println(error.localizedDescription)
        })

But I get back an error from the server saying the content type is not valid. So I tried changing (in the OAuthSwiftClient) where it says request.encodeParameters = true to request.encodeParameters = false, and this gives me the error from the server saying the application's authentication failed, and the OAuth signature is not included in the response string.

I should probably add that doing a GET request works fine.

Has anybody else had these problems?

Support for OS X?

OAuthSwift uses UIKit, so I'm guessing this won't work for an OS X application. Are you going to add support?

Swift 1.2

Swift 1.2 support would be awesome!

Problem with authenticating via Tumblr

Hi,

I'm currently trying to authenticate via Tumblr OAuth1. Unfortunately I'm always getting the following error when coming back from Mobile Safari:

Error Domain=oauthswift.error Code=-1 "The operation couldn’t be completed. Oauth problem." UserInfo=0x7fc56290abe0 {NSLocalizedFailureReason=Oauth problem.}

I'm using the following URLs as mentioned on Tumblr docs

let requestTokenURL = "http://www.tumblr.com/oauth/request_token"
let authorizeURL = "http://www.tumblr.com/oauth/authorize"
let accessTokenURL = "http://www.tumblr.com/oauth/access_token"

Tumblr's documentation stated that their implementation is very similar with Twitter, but if I change the key/secret and the URLs to Twitter's API everything works fine.

Does anyone know what kind of problem I'm facing here? Could this be an Issue with the OAuth Library itself?

Thanks!

Edit: Tumblr Sends valid oauth_token and oauth_verifier Parameters back. The url looks just like when authenticating against twitter.

Provide a way to create signed URL requests without OAuthSwiftHTTPRequest

The OAuthSwiftClient class does a good job at creating Authorization Headers for the client URL requests, however it seems that the only way to actually send the requests is by using this class directly.

It would be nicer to have a URL request builder based on OAuthSwiftClient that can be used to generate requests, while letting the client decide how to send them (e.g. Alamofire).

I have already built a sample implementation for this:
https://github.com/bizz84/OAuthRequestBuilderSwift

Would be nice to see this integrated into OAuthSwiftClient.

Can´t build the project

Hello, I was trying to use your repo, but when build its fail. idk why, please help. Im interested on this repo. Adjunct the representative image

screen shot 2015-03-30 at 9 23 07 am

Setting the Callback URL in the app

I'm new to Xcode and I'm not sure how to set the Callback URL for the Linkedin app in the Linkedin web page or in the Demo app [oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/linkedin")!, scope: "r_fullprofile", state: "", success: { ]. I'd appreciate your help!

Almost! Crashing on Instagram with latest build.

  1. DL latest build
  2. Set up Podfile
  3. Add my ID, and secret key. That's it. Pretty simple.
  4. Run Demo

OAuth verification on mobile is not easy, that we know.

Kaboom! What the heck is going on. I'm confused a bit by this one. There is nothing optional here. Error does not show up at compile time. Only at run time. So close! Thanks.

screen shot 2015-04-13 at 8 33 48 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.