[GH-ISSUE #377] Add client_credential grant_type #243

Closed
opened 2026-03-03 16:46:59 +03:00 by kerem · 1 comment
Owner

Originally created by @AlexanderPetrovichev on GitHub (May 25, 2017).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/377

Description:

I'm developing iPhone SDK for my server with oauth and I need client_credentials authorization.

I found this method
open func authorize(deviceToken deviceCode: String, success: @escaping TokenRenewedHandler, failure: @escaping OAuthSwiftHTTPRequest.FailureHandler) -> OAuthSwiftRequestHandle? {
var parameters = OAuthSwift.Parameters()
parameters["client_id"] = self.consumerKey
parameters["client_secret"] = self.consumerSecret
parameters["code"] = deviceCode
parameters["grant_type"] = "http://oauth.net/grant_type/device/1.0"

    return requestOAuthAccessToken(
        withParameters: parameters,
        success: { (credential, response, parameters) in
            success(credential)
        }, failure: failure
    )
}

And if I change
parameters["grant_type"] = "http://oauth.net/grant_type/device/1.0"
to
parameters["grant_type"] = "client_credentials"
authorization will work.
But since I want to distribute my SDK to another developers I need some way to add this functionality to master. Or can you offer me another way to set client_credentials into grant_type field?

OAuth Provider (Twitter, Github, ..):

Other

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 @AlexanderPetrovichev on GitHub (May 25, 2017). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/377 ### Description: I'm developing iPhone SDK for my server with oauth and I need client_credentials authorization. I found this method open func authorize(deviceToken deviceCode: String, success: @escaping TokenRenewedHandler, failure: @escaping OAuthSwiftHTTPRequest.FailureHandler) -> OAuthSwiftRequestHandle? { var parameters = OAuthSwift.Parameters() parameters["client_id"] = self.consumerKey parameters["client_secret"] = self.consumerSecret parameters["code"] = deviceCode parameters["grant_type"] = "http://oauth.net/grant_type/device/1.0" return requestOAuthAccessToken( withParameters: parameters, success: { (credential, response, parameters) in success(credential) }, failure: failure ) } And if I change parameters["grant_type"] = "http://oauth.net/grant_type/device/1.0" to parameters["grant_type"] = "client_credentials" authorization will work. But since I want to distribute my SDK to another developers I need some way to add this functionality to master. Or can you offer me another way to set client_credentials into grant_type field? ### OAuth Provider (Twitter, Github, ..): Other ### OAuth Version: - [ ] Version 1 - [x] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Manually ### Library version: - [x] 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:47:00 +03:00
Author
Owner

@phimage commented on GitHub (Jun 4, 2017):

you can know specify grantType in function parameters

next time try to make a PR

<!-- gh-comment-id:306029185 --> @phimage commented on GitHub (Jun 4, 2017): you can know specify grantType in function parameters next time try to make a PR
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#243
No description provided.