Я создаю android приложение, которое использует REST apis из серверной части с весенней загрузкой, которую я запускаю на своем устройстве (localhost). Приложение android использует для этой цели модификацию.
, но я не могу попасть ни в один из API, не используя ни мое android устройство, ни эмулятор.
Я попробовал большинство ответов, представленных на разных форумах, для этого , но так и не смог найти ответ.
То, что я пробовал до сих пор;
Запуск на эмуляторе
изменение базового URL на have 10.0.2.2:portNo - не дал ответа
изменив настройку эмулятора> Прокси для получения IP-адреса сети - выдает следующее в бэкэнд-сервисе Springbok - source
Request received for GET '/gen_204':
org.apache.catalina.connector.RequestFacade@19ebbc48
servletPath:/gen_204
pathInfo:null
headers:
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.32 Safari/537.36
host: www.google.com
connection: Keep-Alive
accept-encoding: gzip
Security filter chain: [
WebAsyncManagerIntegrationFilter
SecurityContextPersistenceFilter
HeaderWriterFilter
CorsFilter
LogoutFilter
JWTAuthenticationFilter
RequestCacheAwareFilter
SecurityContextHolderAwareRequestFilter
AnonymousAuthenticationFilter
SessionManagementFilter
ExceptionTranslationFilter
FilterSecurityInterceptor
]
************************************************************
2020-03-12 15:45:21.473 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2020-03-12 15:45:21.474 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2020-03-12 15:45:21.474 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2020-03-12 15:45:21.475 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 4 of 12 in additional filter chain; firing Filter: 'CorsFilter'
2020-03-12 15:45:21.477 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 5 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
2020-03-12 15:45:21.477 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 6 of 12 in additional filter chain; firing Filter: 'JWTAuthenticationFilter'
2020-03-12 15:45:21.477 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 7 of 12 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2020-03-12 15:45:21.477 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 8 of 12 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2020-03-12 15:45:21.477 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 9 of 12 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2020-03-12 15:45:21.477 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 10 of 12 in additional filter chain; firing Filter: 'SessionManagementFilter'
2020-03-12 15:45:21.477 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 11 of 12 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2020-03-12 15:45:21.477 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /gen_204 at position 12 of 12 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2020-03-12 15:45:21.477 INFO 36507 --- [nio-8080-exec-7] l.a.e.o.A.JwtAuthenticationEntryPoint : Unauthorized error. Message - Full authentication is required to access this resource
2020-03-12 15:45:21.478 INFO 36507 --- [nio-8080-exec-7] Spring Security Debugger :
************************************************************
Request received for GET '/error':
org.apache.catalina.core.ApplicationHttpRequest@78d558cf
servletPath:/error
pathInfo:null
headers:
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.32 Safari/537.36
host: www.google.com
connection: Keep-Alive
accept-encoding: gzip
Security filter chain: [
WebAsyncManagerIntegrationFilter
SecurityContextPersistenceFilter
HeaderWriterFilter
CorsFilter
LogoutFilter
JWTAuthenticationFilter
RequestCacheAwareFilter
SecurityContextHolderAwareRequestFilter
AnonymousAuthenticationFilter
SessionManagementFilter
ExceptionTranslationFilter
FilterSecurityInterceptor
]
************************************************************
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 4 of 12 in additional filter chain; firing Filter: 'CorsFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 5 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 6 of 12 in additional filter chain; firing Filter: 'JWTAuthenticationFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 7 of 12 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 8 of 12 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 9 of 12 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 10 of 12 in additional filter chain; firing Filter: 'SessionManagementFilter'
2020-03-12 15:45:21.478 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 11 of 12 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2020-03-12 15:45:21.480 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error at position 12 of 12 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2020-03-12 15:45:21.480 DEBUG 36507 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : /error reached end of additional filter chain; proceeding with original chain
, где '/ gen_204' используется Google, чтобы проверить, подключено ли устройство к сети, что в этом случае не удается.
соединение с устройством
попытался использовать одинаковые сети Wi-Fi и точки доступа для обоих устройств, но безуспешно.
использование кода применительно к модернизации;
public interface AuthApis {
@POST("login")
Call<LoginRequest> signInUser(@Body LoginRequest loginRequest);
@POST("register")
Call<UserDTO> registerUser(@Body UserDTO dto);
}
public class RegistrationActivity extends AppCompatActivity {
private EditText name_et;
private EditText email_et;
private EditText password_et;
private EditText confirmpass_et;
private AuthApis authApis;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
getSupportActionBar().setTitle("Registration");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
this.name_et=findViewById(R.id.unameET);
this.email_et=findViewById(R.id.emailET);
this.password_et=findViewById(R.id.passET);
this.confirmpass_et=findViewById(R.id.confirmPassET);
Retrofit retrofit=new Retrofit.Builder()
.baseUrl("http://localhost:8080/auth/")
.addConverterFactory(GsonConverterFactory.create())
.build();
authApis=retrofit.create(AuthApis.class);
}
public void signupBtn_onClick(View view) {
String name = name_et.getText().toString();
String email = email_et.getText().toString();
String password = password_et.getText().toString();
String confirm_password = confirmpass_et.getText().toString();
UserDTO dto=new UserDTO();
dto.setUserName(name);
dto.setEmail(email);
dto.setPassword(password);
dto.setConfirmPassword(confirm_password);
Call<UserDTO> userDTOCall=authApis.registerUser(dto);
userDTOCall.enqueue(new Callback<UserDTO>() {
@Override
public void onResponse(Call<UserDTO> call, Response<UserDTO> response) {
if(!response.isSuccessful()){
System.out.println(response.code());
}
System.out.println(response.body());
}
@Override
public void onFailure(Call<UserDTO> call, Throwable t) {
}
});
}
}
Приведенный выше код, когда отлажен, остановится после вызова метода call.enqueue
Я хотел бы знать, что Это может быть не так. любая помощь приветствуется.