// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
//     public static final String HOST = "https://api.500px.com/";
// 
//     public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
//             HttpLoggingInterceptor.Level.HEADERS;
// 
// 
//     public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
//     public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
//     public static final String AUTH_CALLBACK_URL = "";
// 
//     public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
//     public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
// 
//     public static final String X_AUTH_MODE = "client_auth";
//     public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
//     public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
// 
//     public static final String USERNAME = X_AUTH_USERNAME;
// }


import com.jagsaund.rxuploader.sample.config.Config;
import oauth.signpost.AbstractOAuthProvider;
import oauth.signpost.http.HttpRequest;
import oauth.signpost.http.HttpResponse;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.Util;
import se.akerfeldt.okhttp.signpost.OkHttpRequestAdapter;
import se.akerfeldt.okhttp.signpost.OkHttpResponseAdapter;
package com.jagsaund.rxuploader.sample.service;


public class XOAuthProvider extends AbstractOAuthProvider {

    private transient OkHttpClient okHttpClient;

    public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
                               String authorizationWebsiteUrl) {
        super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
        this.okHttpClient = new OkHttpClient();
    }

    public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
                               String authorizationWebsiteUrl, OkHttpClient okHttpClient) {
        super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
        this.okHttpClient = okHttpClient;
    }

    public void setOkHttpClient(OkHttpClient okHttpClient) {
        this.okHttpClient = okHttpClient;
    }

    @Override
    protected HttpRequest createRequest(String endpointUrl) throws Exception {
        final Request.Builder builder =
                new Request.Builder()
                        .url(endpointUrl)
                        .post(Util.EMPTY_REQUEST);
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
//     public static final String HOST = "https://api.500px.com/";
// 
//     public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
//             HttpLoggingInterceptor.Level.HEADERS;
// 
// 
//     public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
//     public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
//     public static final String AUTH_CALLBACK_URL = "";
// 
//     public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
//     public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
// 
//     public static final String X_AUTH_MODE = "client_auth";
//     public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
//     public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
// 
//     public static final String USERNAME = X_AUTH_USERNAME;
// }


// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/XOAuthProvider.java
import com.jagsaund.rxuploader.sample.config.Config;
import oauth.signpost.AbstractOAuthProvider;
import oauth.signpost.http.HttpRequest;
import oauth.signpost.http.HttpResponse;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.Util;
import se.akerfeldt.okhttp.signpost.OkHttpRequestAdapter;
import se.akerfeldt.okhttp.signpost.OkHttpResponseAdapter;

package com.jagsaund.rxuploader.sample.service;


public class XOAuthProvider extends AbstractOAuthProvider {

    private transient OkHttpClient okHttpClient;

    public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
                               String authorizationWebsiteUrl) {
        super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
        this.okHttpClient = new OkHttpClient();
    }

    public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
                               String authorizationWebsiteUrl, OkHttpClient okHttpClient) {
        super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
        this.okHttpClient = okHttpClient;
    }

    public void setOkHttpClient(OkHttpClient okHttpClient) {
        this.okHttpClient = okHttpClient;
    }

    @Override
    protected HttpRequest createRequest(String endpointUrl) throws Exception {
        final Request.Builder builder =
                new Request.Builder()
                        .url(endpointUrl)
                        .post(Util.EMPTY_REQUEST);
        if (endpointUrl.contains(Config.ACCESS_TOKEN_URL)) {