[GH-ISSUE #503] Newb question #332

Closed
opened 2026-03-03 16:47:46 +03:00 by kerem · 6 comments
Owner

Originally created by @EdwardD20 on GitHub (Jan 4, 2019).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/503

Description:

  1. Will this work with Yahoo, specifically Yahoo Weather as it now requires OAuth1 (https://developer.yahoo.com/weather/)?

  2. I followed the "simplest way to add it to your app" instructions and the 4 steps. Are the other steps (Carthage, CocoaPods also required?

  3. macOS development - when I added import OAuthSwift to my AppDelegate.swift code, I get the error: No such module 'OAuthSwift'

OAuth Provider? (Twitter, Github, ..):

Yahoo

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

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

Installation method:

  • Carthage
  • CocoaPods
  • Manually

Library version:

  • head
  • v1.2.1
  • v1.2 (Swift 4.0)
  • v1.0.0
  • v0.6
  • other: (Please fill in the version you are using.)

Xcode version:

  • 9.3 (Swift 4.1)

  • 9.0 (Swift 4.0)

  • 9.0 (Swift 3.2)

  • 8.x (Swift 3.x)

  • 8.0 (Swift 2.3)

  • 7.3.1

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

  • objective c

Originally created by @EdwardD20 on GitHub (Jan 4, 2019). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/503 ### Description: 1) Will this work with Yahoo, specifically Yahoo Weather as it now requires OAuth1 (https://developer.yahoo.com/weather/)? 2) I followed the "**_simplest way to add it to your app_**" instructions and the 4 steps. Are the other steps (Carthage, CocoaPods also required? 3) macOS development - when I added **import OAuthSwift** to my AppDelegate.swift code, I get the error: **No such module 'OAuthSwift'** ### OAuth Provider? (Twitter, Github, ..): Yahoo ### OAuth Version: - [X] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [ ] iOS : - [X] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [ ] CocoaPods - [X] Manually ### Library version: - [X] head - [ ] v1.2.1 - [ ] v1.2 (Swift 4.0) - [ ] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [ ] 9.3 (Swift 4.1) - [ ] 9.0 (Swift 4.0) - [ ] 9.0 (Swift 3.2) - [ ] 8.x (Swift 3.x) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1 - [X] other: Xcode 10.1 (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:47:47 +03:00
Author
Owner

@EdwardD20 commented on GitHub (Jan 5, 2019):

I may have started to figure this out. For macOS, instead of the Build Phase/Target Dependency of OAuthSwift, it needs to be OAuthSwiftMacOS. The Deployment Target also requires 10.10 or higher.

<!-- gh-comment-id:451669284 --> @EdwardD20 commented on GitHub (Jan 5, 2019): I may have started to figure this out. For macOS, instead of the Build Phase/Target Dependency of OAuthSwift, it needs to be OAuthSwiftMacOS. The Deployment Target also requires 10.10 or higher.
Author
Owner

@EdwardD20 commented on GitHub (Jan 6, 2019):

How can I get my OAuth1Swift/oauthswift.client.get call to run synchronously?

<!-- gh-comment-id:451779764 --> @EdwardD20 commented on GitHub (Jan 6, 2019): How can I get my OAuth1Swift/oauthswift.client.get call to run synchronously?
Author
Owner

@phimage commented on GitHub (Jan 7, 2019):

Why do you want to do that?
It is often a bad practice. You can add a semaphore to wait in calling thread but you will block the thread

Maybe try to achieve beautiful code with promise/future or rxswift

Ps: next time create a new topic for a new question and close the resolved one.

<!-- gh-comment-id:451845299 --> @phimage commented on GitHub (Jan 7, 2019): Why do you want to do that? It is often a bad practice. You can add a semaphore to wait in calling thread but you will block the thread Maybe try to achieve beautiful code with promise/future or rxswift Ps: next time create a new topic for a new question and close the resolved one.
Author
Owner

@EdwardD20 commented on GitHub (Jan 7, 2019):

M. Marchand - Sorry for not following the protocols. I am new to GitHub and new to this OAuth process. I am grateful that you put this together.

I didn't want to open too many "newb" questions and clutter up the queue.

For the Installation, I determined the problem but nothing was fixed so I don't feel I should close the Issue. The main page needs to change to:

  • Expand the Target Dependencies group, and add OAuthSwift framework for iOS and OAuthSwiftMacOS framework for macOS.

For the sync code, I tried added these couple of lines but it isn't working. Can you suggest another option?

    // create an OAuth instance and retain it
    let oauthswift = OAuth1Swift(
        consumerKey:    ak1,
        consumerSecret: ak2
    )

    **let group = DispatchGroup()
    group.enter()**
    
    // do your HTTP request without authorize
    oauthswift.client.get(parseURL,
                          success: { response in
                            data = response.data
                            **group.leave()**
    },
                          failure: { error in
                            print(error)
                            **group.leave()**
    }
    )

    // wait ...
    **group.wait()**

Thank you.

<!-- gh-comment-id:452003524 --> @EdwardD20 commented on GitHub (Jan 7, 2019): M. Marchand - Sorry for not following the protocols. I am new to GitHub and new to this OAuth process. I am grateful that you put this together. I didn't want to open too many "newb" questions and clutter up the queue. For the Installation, I determined the problem but nothing was fixed so I don't feel I should close the Issue. The main page needs to change to: - Expand the Target Dependencies group, and add OAuthSwift framework **for iOS and OAuthSwiftMacOS framework for macOS**. For the sync code, I tried added these couple of lines but it isn't working. Can you suggest another option? // create an OAuth instance and retain it let oauthswift = OAuth1Swift( consumerKey: ak1, consumerSecret: ak2 ) **let group = DispatchGroup() group.enter()** // do your HTTP request without authorize oauthswift.client.get(parseURL, success: { response in data = response.data **group.leave()** }, failure: { error in print(error) **group.leave()** } ) // wait ... **group.wait()** Thank you.
Author
Owner

@EdwardD20 commented on GitHub (Jan 8, 2019):

You specifically mentioned a semaphore so I tried that as well:

    **let semaphore = DispatchSemaphore(value: 1)**

    // do your HTTP request without authorize
    oauthswift.client.get(parseURL,
                          success: { response in
                            data = response.data
                            print(response.string!)
                            **semaphore.signal()**
    },
                          failure: { error in
                            print(error)
                            self.localWeatherFields.title1 = error.description
                            self.localWeatherFields.latitude = error.description
                            **semaphore.signal()**
    }
    )

    // wait ...
    **semaphore.wait()**
<!-- gh-comment-id:452166910 --> @EdwardD20 commented on GitHub (Jan 8, 2019): You specifically mentioned a semaphore so I tried that as well: **let semaphore = DispatchSemaphore(value: 1)** // do your HTTP request without authorize oauthswift.client.get(parseURL, success: { response in data = response.data print(response.string!) **semaphore.signal()** }, failure: { error in print(error) self.localWeatherFields.title1 = error.description self.localWeatherFields.latitude = error.description **semaphore.signal()** } ) // wait ... **semaphore.wait()**
Author
Owner

@phimage commented on GitHub (Jan 8, 2019):

M. Marchand - Sorry for not following the protocols. I am new to GitHub and new to this OAuth process. I am grateful that you put this together.

I didn't want to open too many "newb" questions and clutter up the queue.
That's why you must set an appropriate title, which sumarize your question
Then make new topic, so we could discuss for the first issue, without missing one of the question

For the Installation, I determined the problem but nothing was fixed so I don't feel I should close the Issue. The main page needs to change to:

  • Expand the Target Dependencies group, and add OAuthSwift framework for iOS and OAuthSwiftMacOS framework for macOS.

The xcode target is OAuthSwiftMacOS, the generated framework is called also OAuthSwift
According to the OS, you must drag the good framework into dependencies

For the sync code, I tried added these couple of lines but it isn't working. Can you suggest another option?

    // create an OAuth instance and retain it
    let oauthswift = OAuth1Swift(
        consumerKey:    ak1,
        consumerSecret: ak2
    )

    **let group = DispatchGroup()
    group.enter()**
    
    // do your HTTP request without authorize
    oauthswift.client.get(parseURL,
                          success: { response in
                            data = response.data
                            **group.leave()**
    },
                          failure: { error in
                            print(error)
                            **group.leave()**
    }
    )

    // wait ...
    **group.wait()**

Thank you.
Maybe all the code are not here but I do not see any authentication
You could not make a get just after creating the oauthswift object, there is also an asynchronous authentication method which display the handler (safari) to authenticate

N.B. Then never to this in Main thread, you will block everything, network call must be done in background thread

<!-- gh-comment-id:452210366 --> @phimage commented on GitHub (Jan 8, 2019): > M. Marchand - Sorry for not following the protocols. I am new to GitHub and new to this OAuth process. I am grateful that you put this together. > > I didn't want to open too many "newb" questions and clutter up the queue. That's why you must set an appropriate title, which sumarize your question Then make new topic, so we could discuss for the first issue, without missing one of the question > > For the Installation, I determined the problem but nothing was fixed so I don't feel I should close the Issue. The main page needs to change to: > > * Expand the Target Dependencies group, and add OAuthSwift framework **for iOS and OAuthSwiftMacOS framework for macOS**. The xcode target is OAuthSwiftMacOS, the generated framework is called also OAuthSwift According to the OS, you must drag the good framework into dependencies > For the sync code, I tried added these couple of lines but it isn't working. Can you suggest another option? > > ``` > // create an OAuth instance and retain it > let oauthswift = OAuth1Swift( > consumerKey: ak1, > consumerSecret: ak2 > ) > > **let group = DispatchGroup() > group.enter()** > > // do your HTTP request without authorize > oauthswift.client.get(parseURL, > success: { response in > data = response.data > **group.leave()** > }, > failure: { error in > print(error) > **group.leave()** > } > ) > > // wait ... > **group.wait()** > ``` > Thank you. Maybe all the code are not here but I do not see any authentication You could not make a get just after creating the oauthswift object, there is also an asynchronous authentication method which display the handler (safari) to authenticate N.B. Then never to this in Main thread, you will block everything, network call must be done in background thread
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#332
No description provided.