Skip to content
This repository was archived by the owner on Jan 9, 2021. It is now read-only.

Commit d319f5d

Browse files
committed
Fix bug where redirect_uri not being included with token request.
1 parent 11ddc50 commit d319f5d

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
### 1.0.7 (2016-07-27)
5+
6+
- Fix [Token request does not include redirect_uri as per oauth2 spec](https://github.com/gtritchie/WOPIAuth/issues/8)
7+
48
### 1.0.6 (2016-06-18)
59

610
- Fix [The Refresh button doesn't show the progress control or the Stop Request button](https://github.com/gtritchie/WOPIAuth/issues/1)

WOPIAuth/ConnectionDetailsViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class ConnectionDetailsViewController: NSViewController, ConnectionViewing, Prov
109109
let tokenFetcher = TokenFetcher(tokenURL: tokenUrl, clientId: selectedProvider!.clientId,
110110
clientSecret: selectedProvider!.clientSecret,
111111
authCode: selectedConnection!.refreshToken,
112-
sessionContext: selectedConnection!.sessionContext)
112+
sessionContext: selectedConnection!.sessionContext,
113+
redirectUri: selectedProvider!.redirectUrl)
113114
startRequest(sender, tokenFetcher)
114115
tokenFetcher.fetchTokensUsingCompletionHandler(forRefresh: true) { (result) in
115116
switch result {

WOPIAuth/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>6</string>
24+
<string>7</string>
2525
<key>LSApplicationCategoryType</key>
2626
<string></string>
2727
<key>LSMinimumSystemVersion</key>

WOPIAuth/TokenFetcher.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class TokenFetcher: Fetcher {
3030
private var clientSecret: String
3131
private var authCode: String
3232
private var sessionContext: String
33+
private var redirectUri: String
3334

3435
/// Used to return results from async call
3536
enum FetchTokenResult {
@@ -49,11 +50,12 @@ class TokenFetcher: Fetcher {
4950

5051
// MARK: Life Cycle
5152

52-
init(tokenURL: NSURL, clientId: String, clientSecret: String, authCode: String, sessionContext: String) {
53+
init(tokenURL: NSURL, clientId: String, clientSecret: String, authCode: String, sessionContext: String, redirectUri: String) {
5354
self.clientId = clientId
5455
self.clientSecret = clientSecret
5556
self.authCode = authCode
5657
self.sessionContext = sessionContext
58+
self.redirectUri = redirectUri
5759
super.init(url: tokenURL, errorDomain: "Token Exchange")
5860
}
5961

@@ -86,6 +88,7 @@ class TokenFetcher: Fetcher {
8688
loggingPostParams["grant_type"] = "refresh_token"
8789
} else {
8890
loggingPostParams["grant_type"] = "authorization_code"
91+
loggingPostParams["redirect_uri"] = redirectUri
8992
}
9093
let loggingPostString = formEncodedQueryStringFor(loggingPostParams)
9194

@@ -102,6 +105,7 @@ class TokenFetcher: Fetcher {
102105
postParams["grant_type"] = "refresh_token"
103106
} else {
104107
postParams["grant_type"] = "authorization_code"
108+
postParams["redirect_uri"] = redirectUri
105109
}
106110
let postString = formEncodedQueryStringFor(postParams)
107111

WOPIAuth/WOPIFlowViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ class WOPIFlowViewController: NSViewController, ConnectionCreating {
226226

227227
let tokenFetcher = TokenFetcher(tokenURL: tokenUrl, clientId: provider!.clientId,
228228
clientSecret: provider!.clientSecret, authCode: authCode!,
229-
sessionContext: connection!.sessionContext)
229+
sessionContext: connection!.sessionContext,
230+
redirectUri: provider!.redirectUrl)
230231
activeFetcher = tokenFetcher
231232
tokenFetcher.fetchTokensUsingCompletionHandler(forRefresh: false) { (result) in
232233
switch result {

0 commit comments

Comments
 (0)