XML Flow Tutorial: Getting Tokens

This tutorial demonstrates how an application gets a token for a user.

The first step is the preparatory setup that enables an application to receive user tokens. This setup is done on the eBay Developers Program site (developer.ebay.com).

The second step involves interactions between an application and a user:

The application makes several API calls to eBay during the process of getting a token. When a step includes an API call, it provides a link to XML call samples in the Trading API Call Reference. The samples show how to perform those steps using the API.

What's in this Tutorial

This tutorial contains the following sections:

Back to top

Complete Source Code

The API Flow tutorials use raw XML requests and responses. The XML call samples described in this tutorial can all be found in the Trading API Call Reference.

Before You Begin

All the calls in the tutorial are performed in the Sandbox environment, using a test user and the API Test Tool. If you want to perform the steps in this tutorial for your own application in the Sandbox, you'll need to do the following:

The tutorial has no specific code requirements. You can run the XML samples in the API Test Tool on the eBay Developers Program website (you must log in).

Back to top

Step 1: Setting Up the Application to Receive Tokens

Typically, an application needs to be set up to receive tokens only once.

This section shows how the developer of MagicLister uses the forms in the application settings tab, in the My Account page, to:

  1. The developer signs in to developer.ebay.com and goes to his My Account page. He selects the application settings tab, where he does the following:

  2. Under "Manage Your RuNames," he clicks "Generate RuName." After a minute or so, the page refreshes with a success message and a new RuName. An RuName contains settings that govern:

  3. Under "Manage Your RuNames," he clicks "Show Details" for the new RuName. This opens the form where he sets up application consent details:

    For more information about the fields in this form, click a field for a popup description. Also see Configuring the Consent Flow for Applications with Multiple Users.

    After making changes, click Save Settings.

The MagicLister application is now set up to start getting tokens.

Back to top

Step 2: Getting a Token for a User

This section shows:

  1. Magical Bookseller goes to the MagicLister site, where she clicks a Subscribe button or otherwise lets the application know that she intends to use it.

  2. MagicLister sends a GetSessionID call to eBay, with the MagicLister RuName.

    GetSessionID: retrieves a SessionID that will identify Magical Bookseller after she signs in to eBay.

  3. GetSessionID returns a SessionID to MagicLister.

  4. MagicLister URL-encodes the SessionID and then constructs a URL containing the SessionID and the RuName, and uses this URL to send Magical Bookseller to the eBay Sandbox sign-in page. In this scenario, the GetSessionID call was made using the API Test Tool, and the SessionID was pasted into a URL along with MagicLister's RuName, in a browser window.

    The URL takes this form:

  5. https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn&RuName=YourRuNameHere&SessID=YourSessionIDHere
  6. Magical Bookseller signs in to eBay.

  7. eBay sends Magical Bookseller to the user consent form that MagicLister configured in the application settings tab, in the first section of this scenario.

  8. When Magical Bookseller clicks "I agree," eBay sends her to MagicLister's AcceptURL.

  9. When Magical Bookseller arrives at its AcceptURL, MagicLister sends a FetchToken request to eBay with the SessionID.

    FetchToken: retrieves the token.

    Notice that MagicLister includes its credentials with this FetchToken call--the developer ID, the application ID, and the AuthCert. That's because this is one of the few authenticated user-related calls that you make when you don't already have a token. If you're using SOAP, the credentials need to be in the SOAP header; for XML you include them in the RequesterCredentials field in the request body.

  10. FetchToken returns a user token for Magical Bookseller to MagicLister.

    MagicLister saves the token and the token expiration date from the FetchToken response.

  11. MagicLister tests the token by making a GeteBayOfficialTime request using the new token.

Back to top

Notes and Next Steps

This section contains notes about the tutorial and suggestions for extending it.

What's Next

Here are some suggestions for ways you could modify or extend the tutorial to learn more about the API:

Additional Resources

eBay Knowledge Base includes applications that incorporate the process of getting user tokens. The applications are here:

More information about the eBay Trading API is available at these locations:

Back to top

User-Contributed Notes

Share tips or code samples related to this call or document. Questions or observations are welcome, too.

eBay employees moderate these notes to ensure they're pertinent to the document and relevant to the community. Your submission will show up for all developers when it's activated by the moderator.

   
 
 
 

Back to top




Copyright © 2009–2013 eBay, Inc. All rights reserved. This documentation and the API may only be used in accordance with the eBay Developers Program and API License Agreement.