Spring Google login Callback is not working(Redirect Uri mismatch)

554 views
Skip to first unread message

Rajendra K

unread,
Feb 18, 2015, 5:29:34 AM2/18/15
to pac4j...@googlegroups.com

I am giving my client_id and secret in Config file and changed the callBack url and after signin to google REDIRECT URI MISMATCH.

Can you please slove this and  in the spring you provided after accepting application in Google no redirecting lo result page(showing 404. )


please guide me

thanks in advance.
securityContext.xml

Jérôme LELEU

unread,
Feb 18, 2015, 5:34:41 AM2/18/15
to Rajendra K, pac4j...@googlegroups.com
Hi,

The "Redirect URI mismatch" error says the callback url you define in the Google console is not the right one, you must not forget the ?client_name=Google2Client parameter.

Thanks.
Best regards,
Jérôme


--
You received this message because you are subscribed to the Google Groups "pac4j-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pac4j-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rajendra K

unread,
Feb 19, 2015, 12:32:19 AM2/19/15
to pac4j...@googlegroups.com
Thanks for helping.

Now callback in not Coming properly(Showing 404 /oauth2callback )

In Browser the following will be the URl



 <bean id="clients" class="org.pac4j.core.client.Clients">
        <property name="callbackUrl" value="http://localhost:8081/oauth2callback" />
        <property name="clients">
         <list>
         <ref bean="googleClient" />
         <ref bean="formClient" />
         <ref bean="basicAuthClient" />
         </list>
        </property>
    </bean>
<!-- common to all clients -->
    <bean id="clientFilter" class="org.pac4j.springframework.security.web.ClientAuthenticationFilter">
     <constructor-arg value="/oauth2callback"/>
        <property name="clients" ref="clients" />
        <property name="sessionAuthenticationStrategy" ref="sas" />
        <property name="authenticationManager" ref="authenticationManager" />
    </bean>

Can i  use my own filter by extending clientAuthenticationFilter

I have other question in my current project i am using this security file and now  need to add google login along with this can you please guide me how to interate this 2 and can i use coustom filter for google login and save user details to DB, if so can you show any code example.
Below is the security config file i am using

<http auto-config="true"  use-expressions="true">
<intercept-url pattern="/login" access="permitAll"/>
<intercept-url pattern="/logout" access="permitAll"/>
<intercept-url pattern="/denied" access="hasRole('ROLE_USER')"/>
<intercept-url pattern="/" access="hasRole('ROLE_USER')"/>
<intercept-url pattern="/user" access="hasRole('ROLE_USER')"/>
<intercept-url pattern="/admin" access="hasRole('ROLE_ADMIN')"/>
<form-login login-page="/login" 
authentication-failure-url="/login/failure" 
 authentication-success-handler-ref="loginSuccessHandler" />
<access-denied-handler error-page="/denied"/>
<logout invalidate-session="true" 
logout-success-url="/logout/success" 
logout-url="/logout"/>
</http>
<beans:bean id="customUserDetailsService" class="com......authentication.customUserDetailsService" />
<beans:bean id="loginSuccessHandler" class="com...........authentication.LoginSuccessHandler">
    <beans:property name="defaultTargetUrl" value="/onLogin.htm"/>
    <beans:property name="alwaysUseDefaultTargetUrl" value="true"/>
</beans:bean>
<authentication-manager>
    <authentication-provider user-service-ref="customUserDetailsService" /> 
    <authentication-provider>
        <user-service>
                <user name="admin" password="admin" authorities="ROLE_USER" />
                <user name="superadmin" password="superadmin" authorities="ROLE_USER,ROLE_ADMIN" />
            </user-service>
         <password-encoder hash="md5"/>
        </authentication-provider> 
</authentication-manager>



Thanks in adavnce

Reply all
Reply to author
Forward
0 new messages