Change Google default Auth Redirection - C# (Google liblary)

asp.net-mvc-4, c#, google-api, google-api-dotnet-client

Solution

You can inherit form FlowMetadata and override the AuthCallback property. Take a look in the following link:

https://code.google.com/p/google-api-dotnet-client/source/browse/Src/GoogleApis.Auth.Mvc4/OAuth2/Mvc/FlowMetadata.cs?r=eb702f917c0e18fc960d077af132d0d83bcd6a88#49

BUT, You will be able to change the relative URL but not the absolute one.

If you want to use a totally different URL, you will need to do create your own AuthorizationCodeMvcApp and change its constructor to the following:

public MyNewAuthorizationCodeMvcApp(Controller controller, FlowMetadata flowData)
        : base(
        flowData.Flow,
        < YOUR URL HERE >,
        controller.Request.Url.ToString())
    {
        this.controller = controller;
        this.flowData = flowData;
    }

Then you can plug it to your flow, instead of the default AuthorizationCodeMvcApp (the default implementation of the library).

Problem

I try this code: https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web_applications my code same But! I need change this default url redirection. Now is: redirect_uri=http:%2F%2Flocalhost:52674%2FAuthCallback%2FIndexAsync How I can change this url? Guys please help. Thank you

Original source