1

I am having trouble using OAuthSwift with the Dexcom API (https://developer.dexcom.com/authentication) to get the token and then make a request.

Here is the code that I am currently using to authorize the user with the service by clicking a button that links to the sign on and the redirects back.

import UIKit
import OAuthSwift

class ViewController: UIViewController {

// UI Elements
@IBOutlet weak var resultLabel: UILabel!
@IBAction func authorizeTapped(_ sender: Any) {
    authorizeDexcom()
}

var oauthswift: OAuth2Swift = OAuth2Swift(
    consumerKey: "***",
    consumerSecret: "***",
    authorizeUrl: "https://sandbox-api.dexcom.com/v2/oauth2/login?",
    accessTokenUrl: "https://sandbox-api.dexcom.com/v2/oauth2/token",
    responseType: "code"
)

// Dexcom Test Functions
func authorizeDexcom() {

    oauthswift.allowMissingStateCheck = true
    oauthswift.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oauthswift)

    guard let rdURI = URL(string: "***") else {
        return
    }

    oauthswift.authorize(withCallbackURL: rdURI,
                         scope: "offline_access",
                         state: "",
                         success: { credential, response, parameters in
                            print("SUCCESS")
                            print(credential.oauthToken)

                         }, failure: { error in
                            print(error.localizedDescription)
                         }
    )
}

Can someone direct me to what my next step should be or how I should go about making requests here? When I run my app and click on the button that calls the authorize function, I get what seems to be a token printed in the console but is followed by a few lines of "get output frames failed, state 8196," which leads me to believe that the authorization process is not finishing correctly.

I have looked at the following resources, but have not found anything helpful yet.

Thanks for any help.

Jake Strickler
  • 364
  • 2
  • 11

1 Answers1

3

iOS 12+ has chatty network logging. Your network calls are not failing.

[BoringSSL] nw_protocol_boringssl_get_output_frames(1301) ... get output frames failed, state 8196

This is output every time the URLSession is being cleaned up, or if you call finishTasksAndInvalidate() explicitly.

From what I can tell, there is no way to suppress it without suppressing all OS logging, which is a bad idea. If anyone knows how to suppress this messaging specifically please reply.

smakus
  • 1,107
  • 10
  • 11