首页 > 解决方案 > Google Drive Auth2:如何修复错误 400:redirect_uri_mismatch

问题描述

我正在尝试执行和 auth2 对 google 驱动器的请求,并且收到 redirecturi 不匹配错误。var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecret etc..

   how do we set the redirecturi property to have the same redirect uris has defined when setting up the app?
   It was mentioned the fix for Google Drive v2 but I am using v3 and these are not working.
   I do not see a way, in the code, to set the google drive auth redirect uri.         
   There must be away.

代码如下:

        string[] scopes = new string[] { DriveService.Scope.Drive,
                           DriveService.Scope.DriveFile,};
        var clientId = "txdjxtd.apps.googleusercontent.com";
        var clientSecret = "didididijdiikj";


        var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
        {
            ClientId = clientId,
            ClientSecret = clientSecret
        }, scopes,
        Environment.UserName, CancellationToken.None, new FileDataStore("MyAppsToken")).Result;

请告诉我。谢谢

标签: c#drive

解决方案


推荐阅读