[GH-ISSUE #381] Unable to init Oauth1Swift #244

Closed
opened 2026-03-03 16:47:01 +03:00 by kerem · 1 comment
Owner

Originally created by @vaibhav-varshaaweblabs on GitHub (Jun 7, 2017).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/381

Description:

Following is my code

        let oauth_consumer_key = "**********"
        let oauth_timestamp : String = String(Int(NSDate().timeIntervalSince1970))
        
        let oauth_nonce: String = NSUUID().uuidString
        let nonce = oauth_nonce.replacingOccurrences(of: "-", with: "")
        
        let oauth_consumer_secret = "**********"
        let bytes = Array(oauth_consumer_secret.utf8)
        
        do
        {
            let signature = try HMAC(key: oauth_consumer_secret, variant: .sha256).authenticate(bytes)
            print("Signature - \(signature)")
            
            let parameters = ["oauth_consumer_key": oauth_consumer_key,
                                                           "oauth_signature_method": "HMAC-SHA1",
                                                           "oauth_timestamp": oauth_timestamp,
                                                           "oauth_nonce": nonce,
                                                           "oauth_signature": String.init(describing: signature)] as OAuthSwift.ConfigParameters
            
            
            let oauthswift = OAuth1Swift(parameters: parameters)
            
            let _ = oauthswift?.client.get("URL", success: { (successResponse) in
                print("Response - \(successResponse)")
            }) { (error) in
                print("Error - \(error.localizedDescription)")
            }
        } catch {
            print("Catch")
        }

I always get oauthswift nil

Please guide me where am I going wrong

OAuth Provider (Twitter, Github, ..):

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Manually

Library version:

  • head
  • v1.0.0
  • v0.6
  • other: (Please fill in the version you are using.)
    1.1.2

Xcode version:

  • 8.0 (Swift 3.0)
  • 8.0 (Swift 2.3)
  • 7.3.1
  • other: (Please fill in the version you are using.)
    8.3.2
  • objective c
Originally created by @vaibhav-varshaaweblabs on GitHub (Jun 7, 2017). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/381 ### Description: Following is my code ``` let oauth_consumer_key = "**********" let oauth_timestamp : String = String(Int(NSDate().timeIntervalSince1970)) let oauth_nonce: String = NSUUID().uuidString let nonce = oauth_nonce.replacingOccurrences(of: "-", with: "") let oauth_consumer_secret = "**********" let bytes = Array(oauth_consumer_secret.utf8) do { let signature = try HMAC(key: oauth_consumer_secret, variant: .sha256).authenticate(bytes) print("Signature - \(signature)") let parameters = ["oauth_consumer_key": oauth_consumer_key, "oauth_signature_method": "HMAC-SHA1", "oauth_timestamp": oauth_timestamp, "oauth_nonce": nonce, "oauth_signature": String.init(describing: signature)] as OAuthSwift.ConfigParameters let oauthswift = OAuth1Swift(parameters: parameters) let _ = oauthswift?.client.get("URL", success: { (successResponse) in print("Response - \(successResponse)") }) { (error) in print("Error - \(error.localizedDescription)") } } catch { print("Catch") } ``` I always get ```oauthswift``` nil Please guide me where am I going wrong ### OAuth Provider (Twitter, Github, ..): ### OAuth Version: - [x] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Manually ### Library version: - [ ] head - [ ] v1.0.0 - [ ] v0.6 - [x] other: (Please fill in the version you are using.) 1.1.2 ### Xcode version: - [ ] 8.0 (Swift 3.0) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1 - [x] other: (Please fill in the version you are using.) 8.3.2 - [ ] objective c
kerem 2026-03-03 16:47:01 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@phimage commented on GitHub (Jun 7, 2017):

the parameters are

[
"consumerKey":"..",
"consumerSecret":"..",
"requestTokenUrl":"..",
"authorizeUrl":"..",
"accessTokenUrl":".."
]

If you create yourself your signature, you do not need OAuthSwift, because the aim of this framework is to create the signature according to the request
(oauth1 signature is computed using the URL request and other parameters)

<!-- gh-comment-id:306714334 --> @phimage commented on GitHub (Jun 7, 2017): the parameters are ``` [ "consumerKey":"..", "consumerSecret":"..", "requestTokenUrl":"..", "authorizeUrl":"..", "accessTokenUrl":".." ] ``` If you create yourself your signature, you do not need OAuthSwift, because the aim of this framework is to create the signature according to the request (oauth1 signature is computed using the URL request and other parameters)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#244
No description provided.