Ok, so I'm trying to implement Gmail API on this project, everything I want to do is send an email, this is what I got so far:
- Register a new project at google developers console, enable the gmail API and configure the consent screen.
In consent screen I just changed app name and scopes for gmail.send.
Create my credentials as a webapp and this what I put on redirect uris.
As I'm working with MVC and wanted to use the template with Home controller and Index View, I don't know if this is correct but as far as I know, I must write the page where it should go after the authentication and that's the only page in my project.
Then I download the credentials.json file and add it to my project, then execute this code, ruta is the path to my credentials.json
UserCredential credential;
using (var stream =
new FileStream(ruta, FileMode.Open, FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None).Result;
}
After that I execute the program but I never see the auth page, instead of that, comes the error:
Error 400: redirect_uri_mismatch. The redirect URI in the request, http://127.0.0.1:62297/authorize/, does not match the ones authorized for the OAuth client.
I've tried to add that URI as "http://localhost/authorize" and "http://localhost/authorize/" to my redirect URIs but I keep getting the same error message.
I'm pretty newbie with this, so I'm a bit lost about all this redirect uris, thanks for your answers