Advertisement
Guest User

Untitled

a guest
Sep 1st, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. public class CreatePlaylist extends AsyncTask<String,String,String>
  2. {
  3. private YouTube youtube;
  4. private String token;
  5. private Context context;
  6. public CreatePlaylist(String tk, Context ctx)
  7. {
  8. token = tk;
  9. context = ctx;
  10. }
  11.  
  12. @Override
  13. protected String doInBackground(String... strings)
  14. {
  15. GoogleCredential credential = new GoogleCredential();
  16. credential.setAccessToken(token);
  17. HttpTransport transport = AndroidHttp.newCompatibleTransport();
  18. JsonFactory jsonFactory = new AndroidJsonFactory();
  19. youtube = new YouTube.Builder(transport, jsonFactory, credential)
  20. .setApplicationName("music-info")
  21. .build();
  22. PlaylistSnippet playlistSnippet = new PlaylistSnippet();
  23. playlistSnippet.setTitle("cjg");
  24. playlistSnippet.setDescription("YouTube API v3");
  25. Playlist youTubePlaylist = new Playlist();
  26. youTubePlaylist.setSnippet(playlistSnippet);
  27.  
  28.  
  29. try
  30. {
  31. YouTube.Playlists.Insert playlistInsertCommand =
  32. youtube.playlists().insert("snippet,status", youTubePlaylist);
  33. playlistInsertCommand.execute();
  34. } catch (IOException e)
  35. {
  36. Toast.makeText(context, "IO", Toast.LENGTH_SHORT);
  37. e.printStackTrace();
  38. }
  39. return null;
  40. }
  41. }
  42.  
  43. 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
  44. 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ {
  45. 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ "code": 403,
  46. 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ "errors": [
  47. 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ {
  48. 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ "domain": "global",
  49. 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ "message": "Insufficient Permission",
  50. 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ "reason": "insufficientPermissions"
  51. 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ }
  52. 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ ],
  53. 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ "message": "Insufficient Permission"
  54. 09-01 22:56:33.709 26084-26161/com.example.musicinfo W/System.err﹕ }
  55. 09-01 22:56:33.709 26084-26161/com.example.musicinfo W/System.err﹕ at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
  56. 09-01 22:56:33.709 26084-26161/com.example.musicinfo W/System.err﹕ at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
  57. 09-01 22:56:33.709 26084-26161/com.example.musicinfo W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312)
  58. 09-01 22:56:33.709 26084-26161/com.example.musicinfo W/System.err﹕ at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1049)
  59. 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
  60. 09-01 22:56:33.719 26084-26161/com.example.musicinfo W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
  61. 09-01 22:56:33.719 26084-26161/com.example.musicinfo W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement