2020年12月21日星期一

Retrofit ca not acces /auth endpoint , https not work with auth

I'm trying to connect /auth endpoint in my android app with retrofit2 and okhttp , but the final link is not correct , the other links works good , but this give me 400 Bad Request enter image description here

I do not know why https is not reading, I was tried to put / before auth , to change some options in okhttp , I was thiking problem is in link but nothing, please help me , what can be the problem

  public class ServiceFactory {      public static PaynetService makePaynetService(Context context) {      initializeSSLContext(context);      HttpLoggingInterceptor logging = new HttpLoggingInterceptor();      logging.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);      Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create();      OkHttpClient.Builder okHttpClient;        if (BuildConfig.DEBUG)      {          okHttpClient = UnsafeOkHttpClient.getUnsafeOkHttpClient();      }      else      {          okHttpClient = new OkHttpClient.Builder();      }        okHttpClient.readTimeout(35, TimeUnit.SECONDS)          .connectTimeout(35, TimeUnit.SECONDS)          .addInterceptor(new UnauthorizedInterceptor(context))          .addInterceptor(new HeaderInterceptor(context))          .addInterceptor(new CacheControlInterceptor(context))          .addInterceptor(logging)          .retryOnConnectionFailure(false);            Retrofit retrofit = new Retrofit.Builder().baseUrl(PaynetService.ENDPOINT)              .client(okHttpClient.build())              .addConverterFactory(GsonConverterFactory.create(gson))              .addCallAdapterFactory(RxJavaCallAdapterFactory.create())              .build();        return retrofit.create(PaynetService.class);  }  public static void initializeSSLContext(Context mContext){      try {          SSLContext.getInstance("TLSv1.2");      } catch (NoSuchAlgorithmException e) {          e.printStackTrace();      }      try {          ProviderInstaller.installIfNeeded(mContext.getApplicationContext());      } catch (GooglePlayServicesRepairableException e) {          e.printStackTrace();      } catch (GooglePlayServicesNotAvailableException e) {          e.printStackTrace();      }  }  

}

  @FormUrlEncoded  @POST("auth")  Observable<Response<SignIn>> auth(          @Field("grant_type") String grantType,          @Field("username") String userName,          @Field("password") String password,          @Field("client_id") String clientId,          @Field("device") String deviceName,          @Field("version_app") String appVersion,          @Field("PinCode") String pinCode,          @Field("OtpCode") String otpCode,          @Field("client_secret") String secretKey,          @Field("refresh_token") String refreshToken);  
https://stackoverflow.com/questions/65402406/retrofit-ca-not-acces-auth-endpoint-https-not-work-with-auth December 22, 2020 at 10:07AM

没有评论:

发表评论