Skip to content

uncleanShutdown error #144

@abeazam

Description

@abeazam

when I run this curl:

curl -X "POST" "https://www.googleapis.com/oauth2/v4/token" \
               -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
               --data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer" \
               --data-urlencode "assertion=ddd"

I get this JSON response:

{
  "error": "invalid_request",
  "error_description": "Bad Request"
}

when I run this swift bellow expecting a similar response instead I get "NIOSSL.NIOSSLError.uncleanShutdown"

let bodyStr = "grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=ddd"
        
        let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
        defer {
            try? httpClient.syncShutdown()
        }
        
        
        var request = try HTTPClient.Request(url: "https://www.googleapis.com/oauth2/v4/token", method: .POST)
        request.headers.add(name: "Content-Type", value: "application/x-www-form-urlencoded")
        request.body = .string(bodyStr)

        httpClient.execute(request: request).whenComplete { result in
            switch result {
            case .failure(let error):
                print("error: \(error)")
                //promise.fail(error)
            case .success(let response):
                promise.succeed("success")
                if response.status == .ok {
                    // handle response
                    
                    
                } else {
                    // handle remote error
                }
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions