You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Gmail APIs遇redirect_uri_mismatch错误,求Asp.Net+Angular2解决方案

Fixing the redirect_uri_mismatch Error for Gmail API in ASP.NET API + Angular 2

This error is super common when the redirect URI your app sends in the OAuth authorization request doesn’t exactly match what’s configured in your Google Cloud Console OAuth credentials. Let’s walk through the fix step by step:

  • Navigate to your Google Cloud Console OAuth credentials
    Open your project in Google Cloud Console, then go to APIs & Services > Credentials. Locate the OAuth 2.0 Client ID you created for your app (it should be marked as a "Web application" type).

  • Add the mismatched URI to authorized redirect URIs
    Click the edit icon on your client ID, scroll down to the Authorized redirect URIs section, and add the exact URI from your error: http://127.0.0.1:50528/authorize/. Pay attention to every detail—port numbers, trailing slashes, even 127.0.0.1 vs localhost are treated as different URIs, so don’t swap them out.

  • Double-check your app’s internal configuration
    Make sure your ASP.NET API uses this exact redirect URI in its OAuth setup code. For your Angular 2 frontend, if it’s initiating the auth flow, confirm it’s passing the correct redirect URI to either your backend or directly to the Gmail API endpoint.

  • Wait for configuration changes to propagate
    Google’s credential settings can take a couple of minutes to update. After saving your changes, give it 2-3 minutes before testing again to avoid hitting false errors.

  • Prep for production (later on)
    When you deploy your app to a live environment, don’t forget to add your production domain’s redirect URI (like https://yourappdomain.com/authorize/) to the authorized list—don’t leave only the local development URI in place.

A quick pro tip: If you test locally with both localhost and 127.0.0.1, add both URIs to the authorized list upfront to avoid similar mismatch headaches down the line.

内容的提问来源于stack exchange,提问作者Husam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:33:53