带有 Auth0 的 Angular 应用程序,使用电容器转换为本机应用程序

问题描述 投票:0回答:0

我有一个功能齐全的 Angular 应用程序,它使用 Auth0 进行身份验证。 下一步是使用 Capacitor 转换为本机应用程序。 我关注了这个博客。 https://betterprogramming.pub/how-to-convert-your-angular-application-to-a-native-mobile-app-android-and-ios-c212b38976df

我必须更新 Auth0 中的回调 URL 和注销 URL,关注这个博客。 https://auth0.com/docs/quickstart/native/ionic-angular/01-login

我的 app.module 中的 Auth0 部分看起来像这样

AuthModule.forRoot({
  domain: environment.auth0.domain,
  clientId: environment.auth0.client_id,
  redirectUri: callbackUri,
  audience: `https://${environment.auth0.domain}/api/v2/`,
  useRefreshTokens: true,
  cacheLocation: 'localstorage',
  advancedOptions: {
    defaultScope: 'openid profile read:users update:users update:users_app_metadata update:current_user_metadata',
  },
  scope: 'openid profile',
  httpInterceptor: {
    allowedList: [
      '/api/*',
    ],
  },
}),

而不是 app.module 中的

redirectUri: callbackUri
,我也试过这个

authorizationParams: {
        redirect_uri: callbackUri,
      },

我们获取回调的授权配置如下:

import { isPlatform } from '@ionic/angular';
import config from '../../capacitor.config';
import { environment } from 'src/environments/environment';

const { appId } = config;

export const callbackUri = isPlatform('capacitor')
  ? `${appId}://${environment.auth0.domain}/capacitor/${appId}/callback`
  : environment.baseUrl;

我现在面临的问题是,一旦我点击登录,打开 Auth0 登录页面就会显示“回调 URL 不匹配”。提供的重定向 URL 不在列表中。 此外,重定向 URL 是 http://localhost。我不确定它从哪里获得价值。

我正在从 Android Studio 模拟器测试这个。有没有我可能缺少的配置? 任何帮助表示赞赏。如果需要,非常乐意分享任何其他信息。

android angular ionic-framework auth0 capacitor
© www.soinside.com 2019 - 2024. All rights reserved.