Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor server app with Google Web Authorization error

$
0
0

The integration of YouTubeService in Blazor server application always results in Error 400: redirect_uri_mismatch. The Google Cloud configuration is set for new web application with both Authorised JavaScript origins and Authorised redirect URIs set to https://localhost:5001.How, to setup redirect url to resolve the issue? Is there a need to create dedicated page in blazor app for redirect url.Below is the code with relevant issue.

public class YouTubeApiService{    private YouTubeService _youtubeService;    private readonly string[] Scopes = { YouTubeService.Scope.YoutubeReadonly };    public YouTubeApiService(IConfiguration configuration)    {        _clientSecrets = new ClientSecrets        {            ClientId = configuration["xxxxxxxx"],            ClientSecret = onfiguration["xxxxxxxx"]        };    }    public async Task AuthenticateAsync()    {        using var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read);        // Here new tab is created with  Error 400        var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(            GoogleClientSecrets.FromStream(stream).Secrets,            Scopes,"user",            CancellationToken.None,            new FileDataStore("YouTubeOAuthToken"),            new LocalServerCodeReceiver ());         _youtubeService = new YouTubeService(new BaseClientService.Initializer()        {            HttpClientInitializer = credential,            ApplicationName = "blabal"        });    }}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>