Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Discovery Service

anihojnadel edited this page Oct 28, 2014 · 4 revisions

To learn the proper base URL for accessing a user's OneDrive for Business files, call the Discovery Service. You can use the returned service endpoint URI as the base URL for the FilesClient.

The Discovery Service exposes two different properties, AllServices and Services. AllServices should be used for unauthenticated access. It will return a list with the available services but will not have all the sensible information like endpoint uri or service resource id. Services, will show the services list too, but with all the information for the logged user.

You can use getAllServices() to get general information about services (like the Service Id) and getServices() to get all the information about your particular services (like EndpointUri and ResourceId).

final String baseUrl = "https://api.office.com/discovery/v1.0/me"
DiscoveryClient client = new DiscoveryClient(baseUrl, dependencyResolver); // configure resolver with token beforehand
ListenableFuture<ServiceInfo> odbService = client.getservices().getById("MyFiles@O365_SHAREPOINT").read();
Futures.addCallback(odbService, new FutureCallback<ServiceInfo>() {
                        @Override
                        public void onSuccess(ServiceInfo result) {
                            // use this as base URL: result.getserviceEndpointUri()
                            // use this for OAuth Resource ID: result.getserviceResourceId()
                        }

                        @Override
                        public void onFailure(Throwable t) {

                        }
                    });
Clone this wiki locally