So i’ve just setup an app for the first time on GoogleDrive with the hope of using it as a back end for file storage for an application i’m developing. I just wanted to get some of the Google Drive basis out of the way, like listing files, uploading and renaming but I cannot even get past the Auth.
I have setup a most basic Blazor Server app with the below code. It causes a browser to open with the below error.
@code {
string[] Scopes = { DriveService.Scope.DriveReadonly };
string ApplicationName = "Drive API .NET Quickstart";
UserCredential credential;
protected override async Task OnParametersSetAsync()
{
// credentials.json points to the file containing the client ID and client secret.
var clientSecrets = await GoogleClientSecrets.FromFileAsync("client_secret.json");
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
clientSecrets.Secrets,
new[] { DriveService.ScopeConstants.DriveFile },
"user",
CancellationToken.None);
var driveService = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential
});
}
}
I have however, set the redirect uri in the google console, I also made sure to download the new Secret.json file. However, I also noticed that the port listed in the attached screenshot changes every single time I run the app so no matter what I would do, this error will always come back?
I understand that there are many similar posts but I’ve never seen one mention that the port is always being rotated?
Is there a better way to do this in 2024?