 
                        我在尝试用 Retrofit2 发出请求到公司的OAuth后端取回 access token
基本上就是把下面的curl 命令用Retrofit2写一遍
curl -X POST 
-d "grant_type=password&phone_number=123123123&password=12345" 
-u "Client_Id:Client_Secret" 
http://baseURL/o/token我自己的service接口
public interface LoginService {
    @POST("/o/token")
    @FormUrlEncoded
    Observable<LoginEntity> getAccessToken(@Field("grant_type") String grantType,
                                           @Field("phone_number") String phoneNumber,
                                           @Field("password") String password,
                                           @Header("Authorization") String authorization);
}下面是实现方法
public void login(final MySubscribe<LoginEntity> subscriber, String pn, String psw) {
    mRetrofit = new Retrofit.Builder()
            .baseUrl(MyFeeds.APP_BASE_URL)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .build();  
    //encode pn
    String real_pn = getRealPN(pn);
    //encode the credential using base64 
    String credential = MyFeeds.CLIENT_ID+":"+MyFeeds.CLIENT_SECRET;
    String auth = null;
    try {
        auth = "Basic " + getBase64String(credential);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    LoginService service = mRetrofit.create(LoginService.class);
    Observable<LoginEntity> observable = service.getAccessToken("password", real_pn, psw, auth);
    mSubscription = observable
            .subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(subscriber);
}但我只得到 http500 错误.
有人可以帮下吗? 谢谢
==============
request body
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
500是服务器内部的错误。
应该去检查后台的代码。
参照这里List of HTTP status codes -- 5xx Server Error