Skip to content

Commit

Permalink
Merge pull request OAuthSwift#655 from daironmichel/master
Browse files Browse the repository at this point in the history
optionally change authorize url param names
  • Loading branch information
phimage authored May 13, 2021
2 parents a986697 + c351c8f commit 7e88151
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Sources/OAuth1Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ open class OAuth1Swift: OAuthSwift {

/// Optionally add consumer key to authorize Url (default: false)
open var addConsumerKeyToAuthorizeURL: Bool = false

/// Optionally change the standard `oauth_token` param name of the authorize Url
open var authorizeURLOAuthTokenParam: String = "oauth_token"

/// Optionally change the standard `oauth_consumer_key` param name of the authorize Url
open var authorizeURLConsumerKeyParam: String = "oauth_consumer_key"

/// Encode token using RFC3986
open var useRFC3986ToEncodeToken: Bool = false
Expand Down Expand Up @@ -108,9 +114,9 @@ open class OAuth1Swift: OAuthSwift {
// 2. Authorize
if let token = self.encode(token: credential.oauthToken) {
var urlString = self.authorizeUrl + (self.authorizeUrl.contains("?") ? "&" : "?")
urlString += "oauth_token=\(token)"
urlString += "\(self.authorizeURLOAuthTokenParam)=\(token)"
if self.addConsumerKeyToAuthorizeURL {
urlString += "&oauth_consumer_key=\(self.consumerKey)"
urlString += "&\(self.authorizeURLConsumerKeyParam)=\(self.consumerKey)"
}
if self.addCallbackURLToAuthorizeURL {
urlString += "&oauth_callback=\(callbackURL.absoluteString)"
Expand Down

0 comments on commit 7e88151

Please sign in to comment.