API ERROR

84 views
Skip to first unread message

Yasir Mehmood

unread,
May 22, 2012, 6:38:50 AM5/22/12
to Etsy API V2
Hi,

i am trying to read users listings and profile data but i am not able
to bypass the second step.

Step 1:

require_once 'configuration.php';
// instantiate the OAuth object
// OAUTH_CONSUMER_KEY and OAUTH_CONSUMER_SECRET are constants holding
your key and secret
// and are always used when instantiating the OAuth object
$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);

// make an API request for your temporary credentials
$req_token = $oauth->getRequestToken("http://openapi.etsy.com/v2/oauth/
request_token?scope=email_r%20listings_r%20profile_r%20recommend_rw",
'oob');
print $req_token['login_url'] . "\n";

when i hit the url i get to the authentication page and get
authentication i have given a url in oob to my redirect url where i
have added the code from the PHP API of ETSY.

STEP 2:

require_once 'configuration.php';
// get temporary credentials from the url
$request_token = $_GET['oauth_token'];
// get the temporary credentials secret - this assumes you set the
request secret
// in a cookie, but you may also set it in a database or elsewhere
$request_token_secret = $_COOKIE['request_secret']; // I USED API
SECRET HERE.

// get the verifier from the url
$verifier = $_GET['oauth_verifier'];

$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);

// set the temporary credentials and secret
$oauth->setToken($request_token, $request_token_secret);
try {
// set the verifier and request Etsy's token credentials url
echo $acc_token = $oauth->getAccessToken("http://openapi.etsy.com/
v2/oauth/access_token", null, $verifier);
} catch (OAuthException $e) {
// error_log($e->getMessage());
print($e->getMessage());
}

i get an error message not sure why, can you please pin point it, i
would really appreciate if you could respond me sooner.
the error i get is "Invalid auth/bad request (got a 500, expected HTTP/
1.1 20X or a redirect)".

waiting for you response,

Thanks
Yasir

Charles Clark

unread,
May 22, 2012, 12:28:15 PM5/22/12
to etsy-...@googlegroups.com
Hi Yasir,
  I posted this to your question on Quora as well.  Unless you have specifically requested production API credentials, you only have access to the sandbox api.  The url you are attempting to authenticate against is the production url.  

Try the sandbox url instead.


Charles

Yasir Mehmood

unread,
May 23, 2012, 8:02:17 AM5/23/12
to Etsy API V2
Hi Charles

here are the screenshots for the steps with code i am using so i hope
this would be help full for you to debug.

Step1:
http://tad.iserver.purelogics.info/EtsyAndroid/EtsyAPI/issues/Step1.png

Authentication Page:
http://tad.iserver.purelogics.info/EtsyAndroid/EtsyAPI/issues/Authentication.png

Step2:
http://tad.iserver.purelogics.info/EtsyAndroid/EtsyAPI/issues/Step2.png

Step 2 i get the error.

waiting for your response

Thanks
Yasir

On May 22, 9:28 pm, Charles Clark <ccl...@etsy.com> wrote:
> Hi Yasir,
>   I posted this to your question on Quora as well.  Unless you have
> specifically requested production API credentials, you only have access to
> the sandbox api.  The url you are attempting to authenticate against is the
> production url.
>
> Try the sandbox url instead.
>
> *http://sandbox.openapi.etsy.com/v2*
>
> Charles
>
>
>
>
>
>
>
> On Tuesday, May 22, 2012 6:38:50 AM UTC-4, Yasir Mehmood wrote:
>
> > Hi,
>
> > i am trying to read users listings and profile data but i am not able
> > to bypass the second step.
>
> > Step 1:
>
> > require_once 'configuration.php';
> > // instantiate the OAuth object
> > // OAUTH_CONSUMER_KEY and OAUTH_CONSUMER_SECRET are constants holding
> > your key and secret
> > // and are always used when instantiating the OAuth object
> > $oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
>
> > // make an API request for your temporary credentials
> > $req_token = $oauth->getRequestToken("http://openapi.etsy.com/v2/oauth/
> > request_token?scope=email_r%20listings_r%20profile_r%20recommend_rw<http://openapi.etsy.com/v2/oauth/request_token?scope=email_r%20listin...>",
>
> > 'oob');
> > print $req_token['login_url'] . "\n";
>
> > when i hit the url i get to the authentication page and get
> > authentication i have given a url in oob to my redirect url where i
> > have added the code from the PHP API of ETSY.
>
> > STEP 2:
>
> > require_once 'configuration.php';
> > // get temporary credentials from the url
> > $request_token = $_GET['oauth_token'];
> > // get the temporary credentials secret - this assumes you set the
> > request secret
> > // in a cookie, but you may also set it in a database or elsewhere
> > $request_token_secret = $_COOKIE['request_secret']; // I USED API
> > SECRET HERE.
>
> > // get the verifier from the url
> > $verifier = $_GET['oauth_verifier'];
>
> > $oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
>
> > // set the temporary credentials and secret
> > $oauth->setToken($request_token, $request_token_secret);
> > try {
> >     // set the verifier and request Etsy's token credentials url
> >     echo $acc_token = $oauth->getAccessToken("http://openapi.etsy.com/
> > v2/oauth/access_token <http://openapi.etsy.com/v2/oauth/access_token>",

Jason Wong

unread,
May 23, 2012, 3:33:18 PM5/23/12
to etsy-...@googlegroups.com
Hi Yassir,

Can you send me the etsy username associated with your app keys so i can
look them up and make sure all is ok?

thanks.

cheers,
JW

Amir Khan

unread,
May 23, 2012, 3:36:15 PM5/23/12
to etsy-...@googlegroups.com

hi j, yasir is using amir...@theappdynamics.com . I dnt remember username but above mentioned is the registered email address for etsy account.

Sent from Android.

--
You received this message because you are subscribed to the Google Groups "Etsy API V2" group.
To post to this group, send email to etsy-...@googlegroups.com.
To unsubscribe from this group, send email to etsy-api-v2+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/etsy-api-v2?hl=en.

Jason Wong

unread,
May 23, 2012, 3:56:05 PM5/23/12
to etsy-...@googlegroups.com
Hmm. . . i was just able to successfully use your app keys to authenticate to sandbox.

Perhaps you're not setting the oauth_secret properly? it looks like you're attempting to store it in a cookie after step one, but you're setting request_secret to $req_token['oauth_token'] instead.

cheers,
JW
To unsubscribe from this group, send email to etsy-api-v2...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/etsy-api-v2?hl=en.

--
You received this message because you are subscribed to the Google Groups "Etsy API V2" group.
To post to this group, send email to etsy-...@googlegroups.com.
To unsubscribe from this group, send email to etsy-api-v2...@googlegroups.com.

Amir Khan

unread,
May 23, 2012, 3:59:08 PM5/23/12
to etsy-...@googlegroups.com

Hi Jason. Thank you for investigation. I will let yasir know about your reply. If we encounter any issue we will let you know. Once again thank u for ur prompt reply.
Amir
Sent from Android.

Yasir Mehmood

unread,
May 24, 2012, 6:05:23 AM5/24/12
to Etsy API V2
Hi Jason.

"Perhaps you're not setting the oauth_secret properly? it looks like
you're attempting to store it in a cookie after step one, but you're
setting request_secret to $req_token['oauth_token'] instead. "

it was mentioned in API that you will get an oauth_secret, but i
didn't get it in which parameter i will get that? is it my secret key
which i got from the developers area, or is it something else, kindly
help me out to complete this process, we've things that are dependent
on your API, i would really appreciate if you could help us out, i can
mail you all the files that i am using in my project. I know there is
something that i'm missing, but not sure what it is, if it is
"oauth_secret" then kindly let me know how to get it.

Thanks
Yasir.

On May 24, 12:56 am, Jason Wong <jw...@etsy.com> wrote:
> Hmm. . . i was just able to successfully use your app keys to
> authenticate to sandbox.
>
> Perhaps you're not setting the oauth_secret properly? it looks like
> you're attempting to store it in a cookie after step one, but you're
> setting request_secret to $req_token['oauth_token'] instead.
>
> cheers,
> JW
>
> On 5/23/12 3:36 PM, Amir Khan wrote:
>
>
>
>
>
>
>
>
>
> > hi j, yasir is using amir.k...@theappdynamics.com
> > <mailto:amir.k...@theappdynamics.com> . I dnt remember username but
> > above mentioned is the registered email address for etsy account.
>
> > Sent from Android.
>
> > On May 24, 2012 12:33 AM, "Jason Wong" <jw...@etsy.com
> > <mailto:jw...@etsy.com>> wrote:
>
> >     Hi Yassir,
>
> >     Can you send me the etsy username associated with your app keys so
> >     i can look them up and make sure all is ok?
>
> >     thanks.
>
> >     cheers,
> >     JW
>
> >     On 5/23/12 8:02 AM, Yasir Mehmood wrote:
>
> >         Hi Charles
>
> >         here are the screenshots for the steps with code i am using so
> >         i hope
> >         this would be help full for you to debug.
>
> >         Step1:
> >        http://tad.iserver.purelogics.info/EtsyAndroid/EtsyAPI/issues/Step1.png
>
> >         Authentication Page:
> >        http://tad.iserver.purelogics.info/EtsyAndroid/EtsyAPI/issues/Authent...
>
> >         Step2:
> >        http://tad.iserver.purelogics.info/EtsyAndroid/EtsyAPI/issues/Step2.png
>
> >         Step 2 i get the error.
>
> >         waiting for your response
>
> >         Thanks
> >         Yasir
>
> >         On May 22, 9:28 pm, Charles Clark<ccl...@etsy.com
> >         <mailto:ccl...@etsy.com>>  wrote:
> >     <mailto:etsy-...@googlegroups.com>.
> >     To unsubscribe from this group, send email to
> >     etsy-api-v2...@googlegroups.com
> >     <mailto:etsy-api-v2%2Bunsu...@googlegroups.com>.

Jason Wong

unread,
May 24, 2012, 10:35:52 AM5/24/12
to etsy-...@googlegroups.com
Hi Yassir!

Here's the documentation for the php OAuth::getRequestToken() method:
http://www.php.net/manual/en/oauth.getrequesttoken.php

The return type is an array whose elements are:

Array
(
    [oauth_token] => some_token
    [oauth_token_secret] => some_token_secret
)

cheers,
JW

AmirK

unread,
May 28, 2012, 8:05:59 AM5/28/12
to Etsy API V2
Hi Jason,

Finally we have fixed it. Thank you for your help.

Amir
Reply all
Reply to author
Forward
0 new messages