{"action":"created","issue":{"url":"https://api.github.com/repos/OAuthSwift/OAuthSwift/issues/306","repository_url":"https://api.github.com/repos/OAuthSwift/OAuthSwift","labels_url":"https://api.github.com/repos/OAuthSwift/OAuthSwift/issues/306/labels{/name}","comments_url":"https://api.github.com/repos/OAuthSwift/OAuthSwift/issues/306/comments","events_url":"https://api.github.com/repos/OAuthSwift/OAuthSwift/issues/306/events","html_url":"https://github.com/OAuthSwift/OAuthSwift/issues/306","id":187501400,"number":306,"title":"WordPress OAuth1 returns \"No OAuth parameters supplied\"","user":{"login":"phamdacloc","id":6949354,"avatar_url":"https://avatars.githubusercontent.com/u/6949354?v=3","gravatar_id":"","url":"https://api.github.com/users/phamdacloc","html_url":"https://github.com/phamdacloc","followers_url":"https://api.github.com/users/phamdacloc/followers","following_url":"https://api.github.com/users/phamdacloc/following{/other_user}","gists_url":"https://api.github.com/users/phamdacloc/gists{/gist_id}","starred_url":"https://api.github.com/users/phamdacloc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phamdacloc/subscriptions","organizations_url":"https://api.github.com/users/phamdacloc/orgs","repos_url":"https://api.github.com/users/phamdacloc/repos","events_url":"https://api.github.com/users/phamdacloc/events{/privacy}","received_events_url":"https://api.github.com/users/phamdacloc/received_events","type":"User","site_admin":false},"labels":[{"id":110309099,"url":"https://api.github.com/repos/OAuthSwift/OAuthSwift/labels/help%20wanted","name":"help wanted","color":"159818","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":20,"created_at":"2016-11-05T14:54:18Z","updated_at":"2016-12-02T10:58:05Z","closed_at":null,"body":"\r\n### Description:\r\nI'm running OAuth1 against wordpress but receiving 400 error code: \"No OAuth parameters supplied\"\r\n\r\n```\r\nrequestError[Error Domain=NSURLErrorDomain Code=400 \"HTTP Status 400: Bad Request, Response: No OAuth parameters supplied\" UserInfo={NSErrorFailingURLKey=http://example.us/oauth1/request, NSLocalizedDescription=HTTP Status 400: Bad Request, Response: No OAuth parameters supplied, Response-Headers={\r\n    \"Access-Control-Allow-Headers\" = Authorization;\r\n    Connection = \"keep-alive\";\r\n    \"Content-Type\" = \"text/html; charset=UTF-8\";\r\n    Date = \"Sat, 05 Nov 2016 14:13:54 GMT\";\r\n    \"Keep-Alive\" = \"timeout=15\";\r\n    Server = nginx;\r\n    \"Transfer-Encoding\" = Identity;\r\n}, OAuthSwiftError.response=<NSHTTPURLResponse: 0x600000032320> { URL: http://example.us/oauth1/request } { status code: 400, headers {\r\n    \"Access-Control-Allow-Headers\" = Authorization;\r\n    Connection = \"keep-alive\";\r\n    \"Content-Type\" = \"text/html; charset=UTF-8\";\r\n    Date = \"Sat, 05 Nov 2016 14:13:54 GMT\";\r\n    \"Keep-Alive\" = \"timeout=15\";\r\n    Server = nginx;\r\n    \"Transfer-Encoding\" = Identity;\r\n} }, OAuthSwiftError.response.data=<4e6f204f 41757468 20706172 616d6574 65727320 73757070 6c696564>, Response-Body=No OAuth parameters supplied}]\r\n```\r\n\r\nHere is the test functions:\r\n\r\n```\r\nclass ViewController: OAuthViewController {\r\n    \r\n    // oauth swift object (retain)\r\n    var oauthswift: OAuthSwift?\r\n\r\n    lazy var internalWebViewController: WebViewController = {\r\n        let controller = WebViewController()\r\n        controller.view = UIView(frame: UIScreen.main.bounds) // needed if no nib or not loaded from storyboard\r\n        controller.delegate = self\r\n        controller.viewDidLoad() // allow WebViewController to use this ViewController as parent to be presented\r\n        return controller\r\n    }() \r\n}\r\n\r\nextension ViewController {\r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        \r\n        // init now web view handler\r\n        let _ = internalWebViewController.webView\r\n        \r\n        self.navigationItem.title = \"OAuth\"\r\n        let tableView: UITableView = UITableView(frame: self.view.bounds, style: .plain)\r\n        tableView.delegate = self\r\n        tableView.dataSource = self\r\n        self.view.addSubview(tableView)\r\n        \r\n        self.doOAuthWordpress()\r\n    }\r\n    \r\n    // MARK: Fitbit\r\n    func doOAuthWordpress(){\r\n        let oauthswift = OAuth1Swift(\r\n            consumerKey:    \"xxx\", // Hard coded for now\r\n            consumerSecret: \"yyy\", // Hard coded for now\r\n            requestTokenUrl: \"http://example.us/oauth1/request\",\r\n            authorizeUrl:    \"http://example.us/oauth1/authorize\",\r\n            accessTokenUrl:  \"http://example.us/oauth1/access\"\r\n        )\r\n        \r\n        self.oauthswift = oauthswift\r\n        oauthswift.authorizeURLHandler = getURLHandler()\r\n        \r\n        let _ = oauthswift.authorize(\r\n            withCallbackURL: URL(string: \"oauth-swift://oauth-callback/wordpress\")!,\r\n            success: { credential, response, parameters in\r\n                self.showTokenAlert(name: \"WPTesting\", credential: credential)\r\n            },\r\n            failure: { error in\r\n                print(error.description)\r\n            }\r\n        )\r\n    }\r\n    \r\n    // MARK: handler\r\n    \r\n    func getURLHandler() -> OAuthSwiftURLHandlerType {\r\n        if internalWebViewController.parent == nil {\r\n            self.addChildViewController(internalWebViewController)\r\n        }\r\n        return internalWebViewController\r\n    }\r\n    \r\n    func showTokenAlert(name: String?, credential: OAuthSwiftCredential) {\r\n        var message = \"oauth_token:\\(credential.oauthToken)\"\r\n        if !credential.oauthTokenSecret.isEmpty {\r\n            message += \"\\n\\noauth_toke_secret:\\(credential.oauthTokenSecret)\"\r\n        }\r\n        self.showAlertView(title: name ?? \"Service\", message: message)\r\n        \r\n    }\r\n    \r\n    func showAlertView(title: String, message: String) {\r\n        let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)\r\n        alert.addAction(UIAlertAction(title: \"Close\", style: UIAlertActionStyle.default, handler: nil))\r\n        self.present(alert, animated: true, completion: nil)\r\n    }\r\n    \r\n}\r\n\r\n```\r\n\r\n### OAuth Provider (WordPress):\r\nWP REST API - OAuth 1.0a Server\r\n\r\n### OAuth Version:\r\n- [x] Version 1\r\n- [ ] Version 2\r\n\r\n### OS (Please fill the version) :\r\n- [x] iOS :\r\n- [ ] OSX :\r\n- [ ] TVOS :\r\n- [ ] WatchOS  :\r\n\r\n### Installation method:\r\n- [ ] Carthage\r\n- [ ] CocoaPods\r\n- [x] Manually\r\n\r\n### Library version:\r\n- [ ] head\r\n- [x] v1.0.0\r\n- [ ] v0.6\r\n- [ ] other: (Please fill in the version you are using.)\r\n\r\n### Xcode version:\r\n- [ ] 8.0 (Swift 3.0)\r\n- [ ] 8.0 (Swift 2.3)\r\n- [ ] 7.3.1\r\n- [x] other: (8.1)\r\n\r\n- [ ] objective c\r\n"},"comment":{"url":"https://api.github.com/repos/OAuthSwift/OAuthSwift/issues/comments/264428754","html_url":"https://github.com/OAuthSwift/OAuthSwift/issues/306#issuecomment-264428754","issue_url":"https://api.github.com/repos/OAuthSwift/OAuthSwift/issues/306","id":264428754,"user":{"login":"kangho99","id":5183204,"avatar_url":"https://avatars.githubusercontent.com/u/5183204?v=3","gravatar_id":"","url":"https://api.github.com/users/kangho99","html_url":"https://github.com/kangho99","followers_url":"https://api.github.com/users/kangho99/followers","following_url":"https://api.github.com/users/kangho99/following{/other_user}","gists_url":"https://api.github.com/users/kangho99/gists{/gist_id}","starred_url":"https://api.github.com/users/kangho99/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kangho99/subscriptions","organizations_url":"https://api.github.com/users/kangho99/orgs","repos_url":"https://api.github.com/users/kangho99/repos","events_url":"https://api.github.com/users/kangho99/events{/privacy}","received_events_url":"https://api.github.com/users/kangho99/received_events","type":"User","site_admin":false},"created_at":"2016-12-02T10:58:05Z","updated_at":"2016-12-02T10:58:05Z","body":"I got into the same situation where the server returns 400.\r\n\r\nIf you made the same mistake I made, this should solve it:\r\nMake sure the \"callback\" url in your wordpress application settings (where you get the key / secret from) and the oauth1swift.authorize() -> withCallbackURL parameter matches."}}
{"actor":{"display_login":"kangho99"}}