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

Commit

Permalink
Fix bug where redirect_uri not being included with token request.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtritchie committed Jul 28, 2016
1 parent 11ddc50 commit d319f5d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

### 1.0.7 (2016-07-27)

- Fix [Token request does not include redirect_uri as per oauth2 spec](https://github.com/gtritchie/WOPIAuth/issues/8)

### 1.0.6 (2016-06-18)

- Fix [The Refresh button doesn't show the progress control or the Stop Request button](https://github.com/gtritchie/WOPIAuth/issues/1)
Expand Down
3 changes: 2 additions & 1 deletion WOPIAuth/ConnectionDetailsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class ConnectionDetailsViewController: NSViewController, ConnectionViewing, Prov
let tokenFetcher = TokenFetcher(tokenURL: tokenUrl, clientId: selectedProvider!.clientId,
clientSecret: selectedProvider!.clientSecret,
authCode: selectedConnection!.refreshToken,
sessionContext: selectedConnection!.sessionContext)
sessionContext: selectedConnection!.sessionContext,
redirectUri: selectedProvider!.redirectUrl)
startRequest(sender, tokenFetcher)
tokenFetcher.fetchTokensUsingCompletionHandler(forRefresh: true) { (result) in
switch result {
Expand Down
2 changes: 1 addition & 1 deletion WOPIAuth/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>6</string>
<string>7</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSMinimumSystemVersion</key>
Expand Down
6 changes: 5 additions & 1 deletion WOPIAuth/TokenFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TokenFetcher: Fetcher {
private var clientSecret: String
private var authCode: String
private var sessionContext: String
private var redirectUri: String

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

// MARK: Life Cycle

init(tokenURL: NSURL, clientId: String, clientSecret: String, authCode: String, sessionContext: String) {
init(tokenURL: NSURL, clientId: String, clientSecret: String, authCode: String, sessionContext: String, redirectUri: String) {
self.clientId = clientId
self.clientSecret = clientSecret
self.authCode = authCode
self.sessionContext = sessionContext
self.redirectUri = redirectUri
super.init(url: tokenURL, errorDomain: "Token Exchange")
}

Expand Down Expand Up @@ -86,6 +88,7 @@ class TokenFetcher: Fetcher {
loggingPostParams["grant_type"] = "refresh_token"
} else {
loggingPostParams["grant_type"] = "authorization_code"
loggingPostParams["redirect_uri"] = redirectUri
}
let loggingPostString = formEncodedQueryStringFor(loggingPostParams)

Expand All @@ -102,6 +105,7 @@ class TokenFetcher: Fetcher {
postParams["grant_type"] = "refresh_token"
} else {
postParams["grant_type"] = "authorization_code"
postParams["redirect_uri"] = redirectUri
}
let postString = formEncodedQueryStringFor(postParams)

Expand Down
3 changes: 2 additions & 1 deletion WOPIAuth/WOPIFlowViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ class WOPIFlowViewController: NSViewController, ConnectionCreating {

let tokenFetcher = TokenFetcher(tokenURL: tokenUrl, clientId: provider!.clientId,
clientSecret: provider!.clientSecret, authCode: authCode!,
sessionContext: connection!.sessionContext)
sessionContext: connection!.sessionContext,
redirectUri: provider!.redirectUrl)
activeFetcher = tokenFetcher
tokenFetcher.fetchTokensUsingCompletionHandler(forRefresh: false) { (result) in
switch result {
Expand Down

0 comments on commit d319f5d

Please sign in to comment.