简体   繁体   中英

OAuth verification failed with seatseller api

i am using seat seller api to retrive some data from seat seller api. they are using oAuth for preventing unauthorized request. They have given me consumer key and consumer secret key to to access their webservice but they havent provided me a oAuth Library. I am littel bit confused how to make my own oAuth library ?

below is the url to get data from webservice

http://api.seatseller.travel/destinations?source=3

if you paste this url, yu can see that "Error: OAUTH verification failed.".

Can anyone guide me how to make HTTP Request with oauth token and secret key?

This is the working solution

This is what i found.

For oauth i was provide consumer key and consumer secret key. I was trying to make authentication request without access token and this can be achieve using below code.

    OAuthConsumer consumer = new DefaultOAuthConsumer(
            "vLrlKnO7XgdH3eu4dvcG5BU9QwCtrQ",
            "AdsphqRmHTvhtZLyiNoCeliLJP2NXZ");
    consumer.setTokenWithSecret(null, null); //i pass token as access token as a null as my server dont need it.

    // create an HTTP request to a protected resource
    URL url = new URL(
            "http://www.mywebservice.com");
    HttpURLConnection request = (HttpURLConnection) url.openConnection();

    // sign the request
    consumer.sign(request);

    // send the request
    request.connect();

    InputStream in = new BufferedInputStream(request.getInputStream());
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    StringBuilder out = new StringBuilder();
    String line = "";
    while ((line = reader.readLine()) != null) {
        out.append(line);
    }
    System.out.println(out.toString());

I use below api for oAuth and Http Connections

  1. commons-codec-1.6.jar
  2. List item
  3. commons-logging-1.1.3.jar
  4. httpclient-4.3.5.jar
  5. httpcore-4.3.2.jar
  6. signpost-commonshttp4-1.2.1.2.jar
  7. signpost-core-1.2.1.2.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM