Я пытался использовать securesocial в игре 2.6.Я использую мастер снимок.Когда я нажимаю на значок GitHub, он переходит ко мне на github.com, и когда я ввожу свое имя пользователя и пароль, я получаю сообщение об ошибке действия не найдено http://localhost:9000/authenticate/github?error=redirect_uri_mismatch&error_description=The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application.&error_uri=https%3A%2F%2Fdeveloper.github.com%2Fapps%2Fmanaging-oauth-apps%2Ftroubleshooting-authorization-request-errors%2F%23redirect-uri-mismatch&state=9eb23bec-37b6-4930-9b76-899ff8e1fbe1.
Ниже приведен мой файл маршрута
GET / controllers.Application.index
GET /home @controllers.Application.goHome
GET /userAware @controllers.Application.userAware
GET /link-result @controllers.Application.linkResult
GET /current-user @controllers.Application.currentUser
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
-> /auth securesocial.Routes
Application.java
package controllers;
import play.mvc.*;
import com.google.inject.Inject;
import play.Logger;
import play.libs.F;
import services.MyUserService;
import securesocial.core.BasicProfile;
import securesocial.core.RuntimeEnvironment;
import securesocial.core.java.SecureSocial;
import securesocial.core.java.SecuredAction;
import securesocial.core.java.UserAwareAction;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import views.html.*;
/**
* This controller contains an action to handle HTTP requests
* to the application's home page.
*/
public class Application extends Controller {
/**
* An action that renders an HTML page with a welcome message.
* The configuration in the <code>routes</code> file means that
* this method will be called when the application receives a
* <code>GET</code> request with a path of <code>/</code>.
*/
public static Logger.ALogger logger = Logger.of("application.controllers.Application");
private RuntimeEnvironment env;
/**
* A constructor needed to get a hold of the environment instance.
* This could be injected using a DI framework instead too.
*
* @param env
*/
@Inject()
public Application (RuntimeEnvironment env) {
this.env = env;
}
/**
* This action only gets called if the user is logged in.
*
* @return
*/
@SecuredAction
public Result index() {
if(logger.isDebugEnabled()){
logger.debug("access granted to index");
}
MyUserService user = (MyUserService) ctx().args.get(SecureSocial.USER_KEY);
return ok(index.render(user, SecureSocial.env()));
}
@UserAwareAction
public Result userAware() {
MyUserService myUser = (MyUserService) ctx().args.get(SecureSocial.USER_KEY);
String userName ;
if ( myUser != null ) {
BasicProfile user = myUser.main;
if ( user.firstName().isDefined() ) {
userName = user.firstName().get();
} else if ( user.fullName().isDefined()) {
userName = user.fullName().get();
} else {
userName = "authenticated user";
}
} else {
userName = "guest";
}
return ok("Hello " + userName + ", you are seeing a public page");
}
@SecuredAction
public Result goHome() {
if(logger.isDebugEnabled()){
logger.debug("access granted to Home");
}
MyUserService user = (MyUserService) ctx().args.get(SecureSocial.USER_KEY);
return ok(home.render());
}
@SecuredAction
public Result linkResult() {
MyUserService current = (MyUserService) ctx().args.get(SecureSocial.USER_KEY);
return ok(linkResult.render(current, current.identities));
}
/**
* Sample use of SecureSocial.currentUser. Access the /current-user to test it
*/
public CompletionStage<Result> currentUser() {
return SecureSocial.currentUser(env).thenApply( new Function<Object, Result>() {
public Result apply(Object maybeUser) {
String id;
if ( maybeUser != null ) {
MyUserService user = (MyUserService) maybeUser;
id = user.main.userId();
} else {
id = "not available. Please log in.";
}
return ok("your id is " + id);
}
});
}
}
И в securesocial.conf я добавил onLoginGoTo = /home