[GH-ISSUE #365] Please help me, how to implement this Postman to OAuthSwift ?? #234

Closed
opened 2026-03-03 16:46:54 +03:00 by kerem · 10 comments
Owner

Originally created by @fermendkis on GitHub (Apr 26, 2017).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/365

Description:

Sir, help me. i am really stuck make OAuth for my API.
so how to implement this Postman to OAuth Swift? please, tell me how code to OAuth get data my API like this picture

image removed

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.)

Xcode version:

  • 8.0 (Swift 3.0)

  • 8.0 (Swift 2.3)

  • 7.3.1

  • other: (Please fill in the version you are using.)

  • objective c

Originally created by @fermendkis on GitHub (Apr 26, 2017). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/365 ### Description: Sir, help me. i am really stuck make OAuth for my API. so how to implement this Postman to OAuth Swift? please, tell me how code to OAuth get data my API like this picture image removed ### OAuth Provider (Twitter, Github, ..): ### OAuth Version: - [x] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [x] Carthage - [ ] CocoaPods - [ ] Manually ### Library version: - [ ] head - [ ] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [x] 8.0 (Swift 3.0) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1 - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:46:55 +03:00
Author
Owner

@phimage commented on GitHub (Apr 26, 2017):

do not put image with your secret informations....
I remove it

try, show your code

<!-- gh-comment-id:297286726 --> @phimage commented on GitHub (Apr 26, 2017): do not put image with your secret informations.... I remove it try, show your code
Author
Owner

@fermendkis commented on GitHub (Apr 26, 2017):

no problem sir, my secret informations is safe. i just want ask how to implement this structure postman in code OAuthSwift. i'm really stuck sir.
screen shot 2017-04-26 at 2 03 03 pm

<!-- gh-comment-id:297311805 --> @fermendkis commented on GitHub (Apr 26, 2017): no problem sir, my secret informations is safe. i just want ask how to implement this structure postman in code OAuthSwift. i'm really stuck sir. <img width="946" alt="screen shot 2017-04-26 at 2 03 03 pm" src="https://cloud.githubusercontent.com/assets/17472847/25427068/8940f0aa-2a9b-11e7-812e-5ecaee77c8c7.png">
Author
Owner

@phimage commented on GitHub (Apr 26, 2017):

go to readme or demo and copy past
look for your provider doc for the url to use

<!-- gh-comment-id:297317108 --> @phimage commented on GitHub (Apr 26, 2017): go to readme or demo and copy past look for your provider doc for the url to use
Author
Owner

@fermendkis commented on GitHub (Apr 26, 2017):

your readme not tell how to add Token Key, Token Secret sir.

<!-- gh-comment-id:297324230 --> @fermendkis commented on GitHub (Apr 26, 2017): your readme not tell how to add Token Key, Token Secret sir.
Author
Owner

@phimage commented on GitHub (Apr 26, 2017):

because that's not real oauth flow
oauth flow allow to obtains token key and secret

the oauth type could be changed to OAuth2?
if yes you do not need oauthSwift, just sign your request by adding a header to your HTTP request

else you can try this "Inject loaded token"
https://github.com/OAuthSwift/OAuthSwift/wiki/Store-credential
and just try to make request

<!-- gh-comment-id:297326462 --> @phimage commented on GitHub (Apr 26, 2017): because that's not real oauth flow oauth flow allow to obtains token key and secret the oauth type could be changed to OAuth2? if yes you do not need oauthSwift, just sign your request by adding a header to your HTTP request else you can try this "Inject loaded token" https://github.com/OAuthSwift/OAuthSwift/wiki/Store-credential and just try to make request
Author
Owner

@fermendkis commented on GitHub (Apr 27, 2017):

oke sir, i'll try.

but how about this? i build code like this to get data and i don't know how next step to add let credential into method get

let credential = OAuthSwiftCredential(consumerKey: oauth_consumer_key, consumerSecret: oauth_consumer_secret)
credential.oauthToken = oauth_token
credential.oauthTokenSecret = oauth_token_secret

<!-- gh-comment-id:297592135 --> @fermendkis commented on GitHub (Apr 27, 2017): oke sir, i'll try. but how about this? i build code like this to get data and i don't know how next step to add **let credential** into method get > let credential = OAuthSwiftCredential(consumerKey: oauth_consumer_key, consumerSecret: oauth_consumer_secret) credential.oauthToken = oauth_token credential.oauthTokenSecret = oauth_token_secret
Author
Owner

@phimage commented on GitHub (Apr 27, 2017):

You must update the one in oauthswift.client
Then use client.get(..)

<!-- gh-comment-id:297629551 --> @phimage commented on GitHub (Apr 27, 2017): You must update the one in oauthswift.client Then use client.get(..)
Author
Owner

@fermendkis commented on GitHub (Apr 28, 2017):

can you give example sir??

<!-- gh-comment-id:297891499 --> @fermendkis commented on GitHub (Apr 28, 2017): can you give example sir??
Author
Owner

@phimage commented on GitHub (Apr 28, 2017):

https://github.com/OAuthSwift/OAuthSwift#make-signed-request
say me if is not clear...

as altermative if you use alamofire you can try the adapter https://github.com/OAuthSwift/OAuthSwiftAlamofire

<!-- gh-comment-id:297923022 --> @phimage commented on GitHub (Apr 28, 2017): https://github.com/OAuthSwift/OAuthSwift#make-signed-request say me if is not clear... as altermative if you use alamofire you can try the adapter https://github.com/OAuthSwift/OAuthSwiftAlamofire
Author
Owner

@fermendkis commented on GitHub (Apr 28, 2017):

i has been tried like this sir

  > let headers = ["Authorization": "OAuth oauth_consumer_key=****,oauth_token=*****,oauth_signature_method=HMAC- 
       ,oauth_timestamp=****,oauth_nonce=KXTM16,oauth_version=1.0,oauth_signature=****",
        "Content-Type": "application/x-www-form-urlencoded"
    ]
    

    Alamofire.request("https://conversation.8villages.com/1.0/contents/articles?state=published", method: .get, headers: headers) .responseJSON { response in
        
        
            print("test", response.request!)  // original URL request
            print("ini responseny", response.response!) // HTTP URL response
            print("test", response.data!)     // server data
            print("test", response.result)   // result of response serialization
            debugPrint(response)
        
            if let JSON = response.result.value {
                print("JSON: \(JSON)")
            }
        }

it's work, i can get my API. but it's just manually im copas Method Signature from Postman. i don't know how to make automatic proccess.

sorry sri, i don't understand with your documentation signed request :(

<!-- gh-comment-id:297930307 --> @fermendkis commented on GitHub (Apr 28, 2017): i has been tried like this sir > let headers = ["Authorization": "OAuth oauth_consumer_key=****,oauth_token=*****,oauth_signature_method=HMAC- ,oauth_timestamp=****,oauth_nonce=KXTM16,oauth_version=1.0,oauth_signature=****", "Content-Type": "application/x-www-form-urlencoded" ] Alamofire.request("https://conversation.8villages.com/1.0/contents/articles?state=published", method: .get, headers: headers) .responseJSON { response in print("test", response.request!) // original URL request print("ini responseny", response.response!) // HTTP URL response print("test", response.data!) // server data print("test", response.result) // result of response serialization debugPrint(response) if let JSON = response.result.value { print("JSON: \(JSON)") } } it's work, i can get my API. but it's just manually im copas Method Signature from Postman. i don't know how to make automatic proccess. sorry sri, i don't understand with your documentation signed request :(
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#234
No description provided.