Skip to content
ChaosSteffen edited this page Sep 14, 2010 · 2 revisions

In addition to the public API, DaWanda has an OAuth API to securely provide access to user-specific data. For further information on what OAuth is and how it works see the official OAuth website.

For using the OAuth API you have to request a consumer key and consumer secret at dawanda.com/apps.

To recieve information you first need to be authorized by the user. To request an authorization do the following:

>> Dawanda::OAuth.connect(OAUTH_KEY, OAUTH_SECRET)
>> redirect_to Dawanda::OAuth.authorize_url

Now the user gets redirected to DaWanda to confirm you, once.

DaWanda will redirect the user back to a given callback URL, where you now can create an ‘Access Token’ to make API requests.

>> Dawanda::OAuth.rebuild(OAUTH_KEY, OAUTH_SECRET, params)
>> @access_token = Dawanda::OAuth.access_token

>> # save access token to user for later use
>> session[:oauth_access_token] = Marshal.dump(@access_token)

You can restore this token at every time to do calls on the API for a specific user. To restore the token you can do the folowing:

>> Dawanda::OAuth.connect(OAUTH_KEY, OAUTH_SECRET)
>> Dawanda::OAuth.access_token = Marshal.load(session[:oauth_access_token])

Now you can do API requests:

>> # get user from dawanda
>> @user = Dawanda::OAuth.user

Clone this wiki locally