SHOW:
|
|
- or go back to the newest paste.
1 | - | SpreadsheetService service = new SpreadsheetService("MySpreadsheetIntegration-v1"); |
1 | + | SpreadsheetService service = new SpreadsheetService("MySpreadsheetIntegration-v1"); |
2 | - | // service.setUserCredentials(<email>, <pw>); |
2 | + | // service.setUserCredentials(<email>, <pw>); |
3 | - | |
3 | + | |
4 | - | GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters(); |
4 | + | GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters(); |
5 | - | oauthParameters.setOAuthConsumerKey("xxx.yyy.no"); |
5 | + | oauthParameters.setOAuthConsumerKey("xxx.yyy.no"); |
6 | - | oauthParameters.setOAuthConsumerSecret("XXX"); |
6 | + | oauthParameters.setOAuthConsumerSecret("XXX"); |
7 | - | oauthParameters.setOAuthToken("YYYY"); |
7 | + | oauthParameters.setOAuthToken("YYYY"); |
8 | - | oauthParameters.setOAuthTokenSecret("ZZZZ"); |
8 | + | oauthParameters.setOAuthTokenSecret("ZZZZ"); |
9 | - | oauthParameters.setScope("https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/"); |
9 | + | oauthParameters.setScope("https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/"); |
10 | - | |
10 | + | |
11 | - | service.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer()); |
11 | + | service.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer()); |
12 | - | |
12 | + | |
13 | - | // Define the URL to request. This should never change. |
13 | + | // Define the URL to request. This should never change. |
14 | - | URL SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full"); |
14 | + | URL SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full"); |
15 | - | |
15 | + | |
16 | - | // Make a request to the API and get all spreadsheets. |
16 | + | // Make a request to the API and get all spreadsheets. |
17 | - | SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class); |
17 | + | SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class); |
18 | - | List<SpreadsheetEntry> spreadsheets = feed.getEntries(); |
18 | + | List<SpreadsheetEntry> spreadsheets = feed.getEntries(); |
19 | - | |
19 | + | |
20 | - | // Iterate through all of the spreadsheets returned |
20 | + | // Iterate through all of the spreadsheets returned |
21 | - | for (SpreadsheetEntry spreadsheet : spreadsheets) { |
21 | + | for (SpreadsheetEntry spreadsheet : spreadsheets) { |
22 | - | // Print the title of this spreadsheet to the screen |
22 | + | // Print the title of this spreadsheet to the screen |
23 | - | System.out.println(spreadsheet.getTitle().getPlainText()); |
23 | + | System.out.println(spreadsheet.getTitle().getPlainText()); |
24 | } | |
25 | ||
26 | WARNING: Authentication error: Unable to respond to any of these challenges: {authsub=WWW-Authenticate: AuthSub realm="https://www.google.com/accounts//AuthSubRequest"} | |
27 | ||
28 | com.google.gdata.util.AuthenticationException: Token invalid - AuthSub token has wrong scope |