Sorry to hear about all the trouble with OAuth2.  If you want to make sure 
that you're rolling through this the right way, at least as far as the 
tokens go, you should check out the OAuth 
Playground<http://googlecodesamples.com/oauth_playground/index.php>
.

I put together this quick demo bash script to get the tokens authorized for 
picasaweb.google.com/data and make that album fetch call.  I'm not saying 
that this is a production-ready script for your application, but it should 
at least get you on the right track.  Let me know if you have more 
questions. Also, fill in the highlighted parts with your information.

#!/bin/bash

#
# Definitions
#

oauthUrl="https://accounts.google.com/o/oauth2/auth";
oauthTokenUrl="https://accounts.google.com/o/oauth2/token";
clientId="..."
clientSecret="..."
basePicasaWebUrl="https://picasaweb.google.com/data";

authUrl="$oauthUrl?client_id=$clientId&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=$basePicasaWebUrl&response_type=code"

# Opens the default browser, in theory.
# Stolen from here: http://www.apreche.net/~apreche/projects/gnome-gmail.txt
BROWSER=`gconftool-2 --get '/desktop/gnome/url-handlers/http/command' | cut 
-f1 -d' ' `

function getAuthToken {
  local cmd="curl $oauthTokenUrl --silent \
      --request POST --header \"Content-Type: 
application/x-www-form-urlencoded\"\
      -d client_id=$clientId -d client_secret=$clientSecret -d 
code=$password \
      -d redirect_uri=urn:ietf:wg:oauth:2.0:oob -d 
grant_type=authorization_code"
  local authResponse=$($cmd)
  echo $authResponse
}

function sendGetRequest {
  curl --silent \
    --header "GData-Version: 2" \
    "$1" | tidy -xml -indent -quiet
  echo
}

#
# Run stuff
#

${BROWSER} $authUrl

echo -n "Oauth2 : "
read password
echo ""

refreshToken=$(getAuthToken)

# Gross stuff to get aout the access token.
# TODO(you): make this better.
authToken=`echo $refreshToken | tr -d '{}'  | sed 
's/.*access_token\":\"\([0-9]\/[-a-zA-Z0-9_]*\).*/\1/'`

sendGetRequest 
"$basePicasaWebUrl/feed/api/user/default?kind=album&oauth_token=$authToken"

-- 
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-picasa-data-api/-/cIlmFaoyST8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-picasa-data-api?hl=en.

Reply via email to