Domanda

I am trying to use the Shiro-Oauth 0.3 plugin with the following set up. Config:

oauth {
    providers {
        google {
            api = org.scribe.builder.api.GoogleApi
            key = 'key'
            secret = 'secret'
            scope = 'https://www.googleapis.com/auth/userinfo.email'
            callback = "${grails.serverURL}/oauth/google/callback"
            successUri = '/oauth/success?provider=google'
            failureUri = '/oauth/failure'
        }
    }
    debug = true
}

security.shiro.oauth.linkAccountUrl = "/oauth/linkaccount"

Build config:

repositories {
    mavenRepo "http://repo.desirableobjects.co.uk/"
}

plugins {
    compile (":shiro:1.2.0") {
        excludes "servlet-api"
    }

    compile ":shiro-oauth:0.3"
}

When I run the project I get the following:

Configuring Shiro ...

| Error 2014-01-14 17:49:04,233 [localhost-startStop-1] ERROR context.GrailsContextLoader  -         Error initializing the application: Error creating bean with name 'uk.co.desirableobjects.oauth.scribe.OauthController': Initialization of bean failed; nested   exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oauthService': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class   [uk.co.desirableobjects.oauth.scribe.OauthService]: Constructor threw exception; nested exception  is java.lang.IllegalArgumentException: Callback must be a valid URL or 'oob'
Message: Error creating bean with name 'uk.co.desirableobjects.oauth.scribe.OauthController': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oauthService': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class  [uk.co.desirableobjects.oauth.scribe.OauthService]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Callback must be a valid URL or 'oob'
   Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   695 | run . .  in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'oauthService': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [uk.co.desirableobjects.oauth.scribe.OauthService]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Callback must be a valid URL or 'oob'
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   695 | run . .  in java.lang.Thread
Caused by BeanInstantiationException: Could not instantiate bean class     [uk.co.desirableobjects.oauth.scribe.OauthService]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Callback must be a valid URL or 'oob'
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   695 | run . .  in java.lang.Thread
Caused by IllegalArgumentException: Callback must be a valid URL or 'oob'
->>  80 | check    in org.scribe.utils.Preconditions
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    66 | checkValidOAuthCallback in     ''
|    87 | callback in org.scribe.builder.ServiceBuilder
|    84 | doCall   in uk.co.desirableobjects.oauth.scribe.OauthService$_buildService_closure1
|    66 | buildService in uk.co.desirableobjects.oauth.scribe.OauthService
|    43 | <init>   in     ''
|   303 | innerRun in java.util.concurrent.FutureTask$Sync
|   138 | run      in java.util.concurrent.FutureTask
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   695 | run . .  in java.lang.Thread
| Error Forked Grails VM exited with error

Anybody any ideas on why this is being caused?

È stato utile?

Soluzione

Is grails.serverURL set in Config.groovy? The OAuth provider will call back to your server, so you must configure a proper URL.

Altri suggerimenti

It happens when you have not configured serverUrl properly, resulting in invalid oauth callback url.

Try this in config.groovy

environments {
production {
      grails.serverUrl = "http://your domain name"
    }

    development {
     grails.serverURL = "http://localhost:8080/your app"
    } 
}

This should fix the error

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top