Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CreatePlaylist extends AsyncTask<String,String,String>
- {
- private YouTube youtube;
- private String token;
- private Context context;
- public CreatePlaylist(String tk, Context ctx)
- {
- token = tk;
- context = ctx;
- }
- @Override
- protected String doInBackground(String... strings)
- {
- GoogleCredential credential = new GoogleCredential();
- credential.setAccessToken(token);
- HttpTransport transport = AndroidHttp.newCompatibleTransport();
- JsonFactory jsonFactory = new AndroidJsonFactory();
- youtube = new YouTube.Builder(transport, jsonFactory, credential)
- .setApplicationName("music-info")
- .build();
- PlaylistSnippet playlistSnippet = new PlaylistSnippet();
- playlistSnippet.setTitle("cjg");
- playlistSnippet.setDescription("YouTube API v3");
- Playlist youTubePlaylist = new Playlist();
- youTubePlaylist.setSnippet(playlistSnippet);
- try
- {
- YouTube.Playlists.Insert playlistInsertCommand =
- youtube.playlists().insert("snippet,status", youTubePlaylist);
- playlistInsertCommand.execute();
- } catch (IOException e)
- {
- Toast.makeText(context, "IO", Toast.LENGTH_SHORT);
- e.printStackTrace();
- }
- return null;
- }
- }
- 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
- 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ {
- 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ "code": 403,
- 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ "errors": [
- 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ {
- 09-01 22:56:33.699 26084-26161/com.example.radioinfo W/System.err﹕ "domain": "global",
- 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ "message": "Insufficient Permission",
- 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ "reason": "insufficientPermissions"
- 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ }
- 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ ],
- 09-01 22:56:33.709 26084-26161/com.example.radioinfo W/System.err﹕ "message": "Insufficient Permission"
- 09-01 22:56:33.709 26084-26161/com.example.musicinfo W/System.err﹕ }
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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