GithubHelp home page GithubHelp logo

Comments (8)

phimage avatar phimage commented on May 22, 2024

NSURLConnection is no more used replaced by NSURLSession with OAuthSwiftHTTPRequest as NSURLSessionDelegate
In the two case there is more to do than stackoverflow code, many way to valid or not (always trust (bad), user/password credential, certificate), count failure, ...

Without an example of server I can't test or develop something, so I will close

If this is necessarry(request it) a delegate parameters could be added to OAuthSwiftHTTPRequest to let framework user custom the behaviours
NSURLSessionTaskDelegate could be used intead of NSURLSessionDelegate

Some code
https://github.com/search?l=swift&q=didReceiveChallenge+&type=Code&utf8=%E2%9C%93
https://gist.github.com/edwardmp/df8517aa9f1752e73353

func URLSession(session: NSURLSession, didReceiveChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential!) -> Void) {
// accept
    completionHandler(NSURLSessionAuthChallengeDisposition.UseCredential, NSURLCredential(forTrust: challenge.protectionSpace.serverTrust))
// or cancel
    completionHandler(NSURLSessionAuthChallengeDisposition.CancelAuthenticationChallenge, nil)

from oauthswift.

makeitTim avatar makeitTim commented on May 22, 2024

Was this (or a way to set my own delegate) ever implemented?

I am using my own id provider, so in the development environment it's a created SSL cert. So this is needed.

from oauthswift.

phimage avatar phimage commented on May 22, 2024

@makeitTim
You can set your own url session delegate for all url session created by oauthswift

var sessionFactory = URLSessionFactory.default
sessionFactory.delegate = <your delegate>

And some framework methods use URLSessionFactory as parameter, for advanced use, and use another factory.

from oauthswift.

makeitTim avatar makeitTim commented on May 22, 2024

Thanks! I just found the SessionFactory struct and have been trying to figure out how to use it.

Xcode does not like the code you gave me, default can only appear in a switch statement. I cannot get it to run.

The convention for singleton naming in Swift seems to be shared:

public static var shared = URLSessionFactory()

from oauthswift.

phimage avatar phimage commented on May 22, 2024

I agree with naming bug with swift 3 you can use default

I edit the code, by replacing ; by =

from oauthswift.

makeitTim avatar makeitTim commented on May 22, 2024

Thanks for the quick response... I don't follow you? What would allow swift to use a variable named default?

from oauthswift.

phimage avatar phimage commented on May 22, 2024

This not a forbidden keyword, go to the URLSessionFactory code and you will see
Just ass some magic quote and you can use default

from oauthswift.

makeitTim avatar makeitTim commented on May 22, 2024

Ok, I was able to access the session factory with var sessionFactory = URLSessionFactory.default. I have not been able to get a self-signed SSL cert to work, even with implementing a URLSessionDelegate. But I think we're gonna try to get a verified certificate for dev anyways as that's a better way to work and Apple will require it in the end.

Keep up the good work!

from oauthswift.

Related Issues (20)

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.