I was searching for a method to view the contents of a public shared google drive folder. I tried Drive Api but unfortunately it doesn't seems to work with this matter. I have read in some threads that the google rest api can do it without any authorization. But I couldn't find any sample code for that. I have the folder ID and I can access/download it via browser.
also found this this
After many hours of searching and testing, I was able to achieve what I was thirsting for. If anyone who had the same problem comes here, I will leave here what I did.
You have to import the json file that has credentials.
Global variables
private static final int REQUEST_AUTHORIZATION = 1;
private final HttpTransport m_transport = AndroidHttp.newCompatibleTransport();
private final JsonFactory m_jsonFactory = GsonFactory.getDefaultInstance();
private GoogleAccountCredential m_credential;
private static Drive m_client;
inside onCreate
m_client = new com.google.api.services.drive.Drive.Builder(
m_transport, m_jsonFactory, credential).setApplicationName("YourAppName")
.build();
You will be able to acquire the json file when you create a OAuth Client ID . However if you just lost the json file by accident, you just have to create a new Service Account Key under the same project and that json file will be get accepted.
After this you will be able to use REST api and can access public shared folders and download/read the contents inside it.