I am authenticating with client id and secret.
String url = String.format("https://login.microsoftonline.com/%s/oauth2/token", tenantContext);
AuthenticationContext context = new AuthenticationContext(url, true, ForkJoinPool.commonPool());
AuthenticationResult result = context.acquireToken("https://graph.microsoft.com", new ClientCredential(clientId, clientSecret), null).get();
String token = result.getAccessTokenType() + " " + result.getAccessToken();
My application has all the permission boxes ticked and with the above token I can list users and traverse their drives and folders. I can access content from https://graph.microsoft.com/v1.0/drives/%s/items/%s/content which returns another URL in the Location header. However when I try to get that URL it returns 401 Unauthorized.
Is the other URL also on graph.microsoft.com? If not, then you need to get a new authentication token for that URL, and then use it in your download requests.
Just like you are already doing with graph.microsoft.com, but with the other server name: