Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #6 from aiten/master

Fixed broken getProvider method.
  • Loading branch information...
commit 61d3975ec676b311fe2db53c789167ddf7663f36 2 parents d555d88 + 71aeda2
Anthony Campbell authored
View
30 oauth-plugin/grails-app/services/org/grails/plugins/oauth/OauthService.groovy
@@ -176,7 +176,7 @@ class OauthService implements InitializingBean {
log?.debug "----- Key: ${token?.key}"
log?.debug "----- Secret: ${token?.secret}"
- consumers[name] = ['key': token?.key, 'secret': token?.secret]
+ consumers[name] = ['key': token?.key, 'secret': token?.secret, 'providerName': key]
}
} else {
log?.error "Error initializaing OauthService: No consumers defined!"
@@ -611,7 +611,7 @@ class OauthService implements InitializingBean {
}
/**
- * Returns the current consumer for the provided name.
+ * Returns the current consumer for the provided consumerName.
*
* @param consumerName the consumer name.
* @return the consumer instance by name.
@@ -620,37 +620,35 @@ class OauthService implements InitializingBean {
* If {@code consumerName} does not represent an existing consumer.
*/
private def getConsumer(final String consumerName) {
- // Get values
+
final def consumerValues = consumers[consumerName]
- // Validate
if (!consumerValues) {
- throw new OauthServiceException("Unknown consumer: '$consumerName'")
+ throw new OauthServiceException("Unknown consumer: consumerName='$consumerName'")
}
- // Initialise new consumer
return new CommonsHttpOAuthConsumer(consumerValues.key, consumerValues.secret)
}
/**
- * Returns the current provider for the provided consumer.
+ * Returns the provider for the provided consumerName.
*
- * @param providerName the provider name.
+ * @param consumerName the consumer name.
* @return the provider instance by name.
*
* @throws OauthServiceException
- * If {@code providerName} does not represent an existing provider.
+ * If {@code consumerName} does not represent an existing provider.
*/
- private def getProvider(final String providerName) {
- // Get values
- final def providerValues = providers[providerName]
+ private def getProvider(final String consumerName) {
- // Validate
- if (!providerValues) {
- throw new OauthServiceException("Unknown provider! (providerName=$providerName)")
+ final String providerName = consumers[consumerName]?.providerName
+
+ if (!providerName) {
+ throw new OauthServiceException("Unknown consumer: consumerName='$consumerName'")
}
- // Initialise new provider
+ final def providerValues = providers[providerName]
+
return new CommonsHttpOAuthProvider(providerValues.requestTokenUrl,
providerValues.accessTokenUrl, providerValues.authUrl, httpClient)
}
Please sign in to comment.
Something went wrong with that request. Please try again.