I am trying to use Google classroom API's to integrate into a product. For that I have created a project in developer console and also created oAuth credentials.
Downloaded the client secret json file.
I am trying to create a class in Google classroom through the API. The code I have used to get access is as follows:
using (var stream = new FileStream(System.Web.HttpContext.Current.Server.MapPath("client_secret.json"), FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(@"C:\googlekeys\.credentials\classroom-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result;
}
when executing the last step it was giving the error Error:
redirect_uri_mismatch
I have cross checked between the developer console and json file that both have the same redirect uris. I have done this process previously for other domains and it has worked great.
Confusing thing for me is that for each and every time I run the code, the redirect uri in the url is changing.
run 1: The redirect URI in the request, http://localhost:51282/authorize/, does not match the ones authorized for the OAuth client
run 2: The redirect URI in the request, http://localhost:44699/authorize/, does not match the ones authorized for the OAuth client
I am very much confused from where it is picking up that redirect url.