Rediret Uri changes automatically

血红的双手。 提交于 2019-12-24 10:40:55

问题


I am using the below code to integrate google drive with my C# example:

protected void Button1_Click(object sender, EventArgs e)
{
    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
               new ClientSecrets
               {
                   ClientId = "********************",
                   ClientSecret = "********************"
               },
               new[] { DriveService.Scope.DriveFile },
               "user",
               CancellationToken.None).Result;

    // Create the service.
    var service = new DriveService(new BaseClientService.Initializer()
    {
        HttpClientInitializer = credential,
        ApplicationName = "Drive API Sample",
    });

    File body = new File();
    body.Title = "My document";
    body.Description = "A test document";
    body.MimeType = "image/jpeg";

    string path = "";

    byte[] byteArray = System.IO.File.ReadAllBytes("D:\\babita_backup\\Babita\\GoogledriveIntegration\\Koala.jpg");
    System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);

    try
    {
        FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "image/jpeg");
        request.Upload();

        File file = request.ResponseBody;
        // Label1.Text = file.Id;
    }
    catch { }
}

And I have: redirect uri as:

https://localhost:50027/GoogleAPI/callback.aspx

javascript origins as:

https://localhost:50027/

But every time when I try to login with the promt I am getting the error:

400 That’s an error. Error: redirect_uri_mismatch The redirect URI in the request: http://localhost:50804/authorize/ did not match a registered redirect URI.

Please note that here the port number changes automatically every time, no matter how many times I change it. Its not picking up the redirect uri that I mentioned in the app console.


回答1:


you need to specify a fix port for the ASP.NET development server like How to fix a port number in asp.NET development server and add this url with the fix port to the allowed urls.



来源:https://stackoverflow.com/questions/25884021/rediret-uri-changes-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!