Git Product home page Git Product logo

auth0-ionic-samples's Introduction

Auth0 Ionic + Capacitor Sample Apps

This repo contains samples that demonstrate how to use Auth0 in an Ionic 5 & Capacitor mobile application.

Prerequisites

The Samples

This repo has the following sample apps:

All samples have been configured to run on desktop, iOS, and Android, and demonstrate:

  • logging into an app
  • logging out of an app
  • showing the user profile

What is Auth0?

Auth0 helps you to:

  • Add authentication with multiple authentication sources, either social like Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others, or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider.
  • Add authentication through more traditional username/password databases.
  • Add support for linking different user accounts with the same user.
  • Support for generating signed JSON Web Tokens to call your APIs and flow the user identity securely.
  • Analytics of how, when and where users are logging in.
  • Pull data from other sources and add it to the user profile, through JavaScript rules.

Create a Free Auth0 Account

  1. Go to Auth0 and click Sign Up.
  2. Use Google, GitHub, or Microsoft Account to log in.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

auth0-ionic-samples's People

Contributors

aaguiarz avatar chenkie avatar dependabot[bot] avatar evansims avatar ewanharris avatar frederikprijck avatar iannyanes avatar jerriep avatar lbalmaceda avatar lobo avatar mehreencs87 avatar mikkimichaelis avatar saltukalakus avatar snyk-bot avatar stevehobbsdev avatar vicsant94 avatar vmartynets avatar widcket avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auth0-ionic-samples's Issues

Angular - iOS auth success, callback called, sample app does not process login

I’ve cloned this repo and am using the angular app. I’ve configured auth.config.ts for my Auth0 app, both domain and clientId are properly set. I’ve added the correct callback and logout urls to Auth0.

I’ve left capacitor.confg.ts alone, leaving appId as 'com.auth0.sample’.

Please correct me at this point if there are additional config instructions for this sample app I have overlooked.

I’m running on an iOS simulator v14.4. I’ve additionally tried on iOS 16.2 with the same results. The first issue is that the Safari browser remains open instead of properly being closed after login - probably not an Auth0 issue, but still something this sample app’s team needs be aware. The second issue is that the sample app produces an error after receiving the auth0 callback. Authorization does not appear to succeed and routing to profile does not happen. The app remains on the Login page.

The Xcode logs are as such:

⚡️ WebView loaded
⚡️ [log] - Angular is running in development mode. Call enableProdMode() to enable production mode.
⚡️ To Native -> App addListener 45681863
⚡️ To Native -> App addListener 45681864
⚡️ To Native -> Browser open 45681865
2022-12-13 20:22:59.108576-0600 App[65759:2372650] Unbalanced calls to begin/end appearance transitions for <Capacitor.TmpViewController: 0x7fc82181cd50>.
⚡️ TO JS undefined
2022-12-13 20:22:59.709564-0600 App[65759:2372650] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
⚡️ TO JS {"url":"com.auth0.samples://xxxxx.us.auth0.com/capacitor/com.auth0.samples/callback?code=kxknQWEblahblahblahblahZ0ndl0JMvoNRs1C&state=OTd5dEhfQ1dIblahblahblahblah80YTVxQw%3D%3D","iosSourceApplication":"com.apple.Saf
⚡️ [error] - ERROR {"isTrusted":true,"message":"Failed to fetch”}

Please help me understand why this sample app is not functioning. I’m following the guide https://auth0.com/docs/quickstart/native/ionic-angular/interactive which led me to this repo. BTW your guide is outdated and contains obvious bugs.

Capacitor login issue

Using the sample app provided for Capacitor/Angular, I am able to log in by pressing the login button which then opens a browser window. However, when I am returned to the app, the login button is still there. If I press it again, I see the logout button along with my user details. It appears that the state is not being changed when you first log in.

UI becomes unresponsive after logout

Summary

I am having an issue when trying to log out from my Ionic app on Android.

  logout() {
    // Use the SDK to build the logout URL
    this.auth
      .buildLogoutUrl({ returnTo: environment.auth0.returnTo })
      .pipe(
        tap(async (url) => {
          // Call the logout fuction, but only log out locally
          this.auth.logout({ localOnly: true });
          // Redirect to Auth0 using the Browser plugin, to clear the user's session
          await Browser.open({ url });
          // Navigate back to the login screen
          this.router.navigateByUrl('/login', { replaceUrl: true });
        }),
      )
      .subscribe();
  }

The code example from this repository also doesn't work

  logout() {
    this.auth
      .buildLogoutUrl({ returnTo: callbackUri })
      .pipe(
        mergeMap(async (url) => {
          await Browser.open({ url, windowName: '_self' });
          this.auth.logout({ localOnly: true });
        })
      )
      .subscribe();
  }

Current behavior

After logging out, the app navigates back to the login page, but the app becomes unresponsive. I cannot log in again until I quit the app.

Expected behavior

I should be able to log in again after logging out. The app should still be responsive after logging out.

Platform

Android 11

Plugins

"@capacitor/app": "^1.1.1",
"@capacitor/browser": "^1.0.7",

outdated dependencies

(AUTH-4223)
Sample using outdated version of angular-auth0 and other dependencies.

Safari cannot open the page because the address is invalid.

Logging in seems to work within the browser, but the browser window never closes nor returns authenticated information to the app.

It seems to be a problem with the redirect uri: YOUR_PACKAGE_ID://YOUR_DOMAIN/capacitor/YOUR_PACKAGE_ID/callback

Might it have something to do with capitalization in the package id? Mine is of the kind com.BundleIdentifier.AndSuch

It appears that Auth0 is correctly redirecting me after logout, but then the SFSafariViewController alerts me that: Safari cannot open the page because the address is invalid.

image

Jumping into the developer console, I see that the accompanying href is about:blank.

Any ideas?

[React] [iOS] Redirect fail after login

I've cloned this repository and it doesn't really seem to work right out of the box. I've followed the instructions (modified auth.config.ts to utilize the correct app ID, added the callback URLs and Logout URLs to my application settings, added the allowed origins, modified the custom URL scheme in the Info tab which isn't in the README) and running the app via the iOS simulator is not working. When I log in, the app does not redirect me anywhere.

I'm seeing the following log:

TO JS {"url":"{redacted app ID}:\/\/{redacted domain}\/capacitor\/{redacted app ID}\/callback?
code=zAcaQU7_2FUrrjvvMzEwaa1j2tZaK4gJZHi64MCld2lnl&
state=Z2RMTXN5RXdzZEFPcW85Qnd1TkdKU0k1Vm4ydWlRM0JLZS1JOUVyUTl%2BNA%3D%3D

so it seems like the app is attempting to perform the redirect, but the app stays on the login page and the browser does not close. Once I manually close the browser and then click "Log in" again, it just shows a blank page in the webview.

Here is a screen recording: https://share.getcloudapp.com/ApuveA7O

[SOLVED] native-run failed with error ERR_UNSUITABLE_API_INSTALLATION

Trying the Ionic & Capacitor (Angular) tutorial, and Android won't launch. I can successfully launch Android from another Ionic project on this computer, so I know my system is set up correctly. Google isn't clear what I need to do next. How can I resolve this?

To get to this point I clicked "Download sample," added the appropriate URLs to the application settings, unpacked it, ran npm install, npm build, npm install @capacitor/android.

$ npx cap run android
√ Copying web assets from www to android\app\src\main\assets\public in 4.33s
√ Creating capacitor.config.json in android\app\src\main\assets in 2.60ms
√ copy android in 4.41s
√ Updating Android plugins in 20.50ms
[info] Found 5 Capacitor plugins for android:
       @capacitor/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
√ update android in 216.66ms
[error] native-run failed with error

        ERR_UNSUITABLE_API_INSTALLATION: No suitable API installation found.

        More details for this error may be available online:
        https://github.com/ionic-team/native-run/wiki/Android-Errors


CBdeV@DAD-E5430 ~/auth0_ionic_test
$

Android failing to load

I’ve cloned the repo, set my values in auth.config.ts, yarn install, ionic cap run android and receive the following errors with the app never completely loading. Please help.

Note ionic cap run iOS works just fine.

2022-12-16 23:08:24.073 11881-11881/com.auth0.samples E/Capacitor/Console: File: http://localhost/ - Line 613 - Msg: SyntaxError: Unexpected token ?

2022-12-16 23:08:24.091 11881-12057/com.auth0.samples E/Capacitor: JavaScript Error: {"type":"js.error","error":{"message":"Uncaught SyntaxError: Unexpected token ?","url":"http://localhost/vendor.js","line":25337,"col":28,"errorObject":"{}”}}

2022-12-16 23:08:24.096 11881-11881/com.auth0.samples E/Capacitor/Console: File: http://localhost/vendor.js - Line 25337 - Msg: Uncaught SyntaxError: Unexpected token ?

2022-12-16 23:08:24.106 11881-11881/com.auth0.samples E/Capacitor/Console: File: http://localhost/ - Line 613 - Msg: SyntaxError: Unexpected token .

2022-12-16 23:08:24.106 11881-12057/com.auth0.samples E/Capacitor: JavaScript Error: {"type":"js.error","error":{"message":"Uncaught SyntaxError: Unexpected token .","url":"http://localhost/main.js","line":104,"col":17,"errorObject":"{}”}}

2022-12-16 23:08:24.133 11881-11881/com.auth0.samples E/Capacitor/Console: File: http://localhost/main.js - Line 104 - Msg: Uncaught SyntaxError: Unexpected token .

does not build after android directory remade

There are changes in the android config, which needed to get the application to run, but are not documented.
I reverse engineered it by deleting the android directory, remaking it by npm run build; npx cap add android, seeing the app being unable to catch the callback uri after authentication to auth0, and adding back changes until it worked again.

Probably this change should be documented, so others do not have to go through this journey.

Add a second intent-filter to android/app/src/main/AndroidManifest.xml

          <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/custom_url_scheme" />
          </intent-filter>

Android App does not open after authentication

Yes, the sample provided when running on Android does automatically open after authentication. What is missing is the reason why in your documentation. Meaning I followed all the documentation to implement auth0/auth0-angular within my application and the Android app would not open. I found that this repository contains within the android/app/src/main/AndroidManifest.xml file the following additional lines

<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="@string/custom_url_scheme" /> </intent-filter>

These lines are not automatically added when running ionic cap platform add android and are required for the proper use of auth0/auth0-angular (and probably react also).

I’m simply pointing this out for anybody else having issues implementing auth0-angular from scratch, or adding it to an existing project. I do suggest updating the online instructions and documentation regarding these samples and resources for implementing auth0-angular.

Infinite loading on android phone

I have twice time: first time i've downloaded samples, replaced credentials, second time i've used download sample from auth0 tutorial. In both cases i've run bower install && ionic state restore --plugins && ionic upload. Using Ionic View on my Meizu m3 note (Android 5.1) tested samples. In both cases got errors: (this one when i'm clicked on social provider icon: twitter, facebook, etc)
s61004-232513
Second one i've got when tried to relogin to database user:
s61004-232435

outdated angular-lock

(AUTH-3927)
Samples using outdated version of angular-lock and doesn't provide oidcConformant and audience parameter.

React same app does not work

Due to #442 I moved capacitor.confg.ts into src allowing to build for the iOS platform.

However the React sample app produces the same behavior as the Angular sample app (please see #441)

Here are the slightly different logs (vs #441) produced by the sample. No errors, Safari still remains open, and Auth0 does nothing.

⚡️ To Native -> App addListener 38238715
⚡️ WebView loaded
⚡️ To Native -> App addListener 38238716
⚡️ To Native -> Browser open 38238717
2022-12-13 21:15:24.715582-0600 App[70777:2440177] Unbalanced calls to begin/end appearance transitions for <Capacitor.TmpViewController: 0x7fdb7250c3f0>.
⚡️ TO JS undefined
⚡️ TO JS {"url":"com.auth0.samples://xxxxxxxxxx.us.auth0.com/capacitor/com.auth0.samples/callback?code=kl4tpQxus..........QdcUO1zs&state=cXdqTX5KZj.......b0JoOWgxTkpLRA%3D%3D","iosSourceApplication":”com.apple.Saf

Would Auth0 support be so kind as to supply a working React Ionic Auth0 sample app?

Thank you so much in advance.......

wants to use both native ios and web so how set call back url for both in react capacitor

Checklist

  • I have looked into the Readme (React/Angular/Vue) and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

wants to use both native ios and web so how set call back url for both in react capacitor

Reproduction

wants to use both native ios and web so how set call back url for both in react capacitor

Additional context

wants to use both native ios and web so how set call back url for both in react capacitor

Sample

React

Platform

iOS

Platform version(s)

xcode

60 sec pause before isAuthenticated$ is fired Angular/Android

uninstall auth0-ionic-samples from android test device
clone this repo
cd auth0-ionic-samples/angular
npm i
update auth.config.ts with domain and client id
ionic cap run android
android is running on test device
Login
Leave app in the foreground for 5 minutes
Close app without Logout
run app
Login button will not be displayed (isAuthenticated$ does not fire at all)
60 seconds later isAuthenticated$ fires and the Login button displays
Once this unusual behavior starts, it can not be stopped w/o an app uninstall

Thank you for your help!

Here is the LogCat output

......
2022-12-23 23:42:42.150 7279-7350/com.auth0.samples W/chromium: [WARNING:display_webview.cc(31)] WebView overlays are enabled!
2022-12-23 23:42:43.748 7279-7279/com.auth0.samples I/Capacitor/Console: File: http://localhost/main.js - Line 207 - Msg: ios: false android: true
2022-12-23 23:42:43.749 7279-7279/com.auth0.samples I/Capacitor/Console: File: http://localhost/main.js - Line 209 - Msg: com.auth0.samples://meetingmaker.us.auth0.com/capacitor/com.auth0.samples/callback
2022-12-23 23:42:44.127 7279-7279/com.auth0.samples I/Capacitor/Console: File: http://localhost/vendor.js - Line 80521 - Msg: Angular is running in development mode. Call enableProdMode() to enable production mode.
2022-12-23 23:42:44.149 7279-7344/com.auth0.samples D/Capacitor: Handling local request: http://localhost/common.js
2022-12-23 23:42:44.149 7279-7336/com.auth0.samples D/Capacitor: Handling local request: http://localhost/node_modules_ionic_core_dist_esm_ion-app_8_entry_js.js
2022-12-23 23:42:44.156 7279-7279/com.auth0.samples V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 129665211, pluginId: App, methodName: addListener
2022-12-23 23:42:44.157 7279-7279/com.auth0.samples V/Capacitor: callback: 129665211, pluginId: App, methodName: addListener, methodData: {"eventName":"appUrlOpen"}
2022-12-23 23:42:44.169 7279-7344/com.auth0.samples D/Capacitor: Handling local request: http://localhost/src_app_home_home_module_ts.js
2022-12-23 23:42:44.492 7279-7336/com.auth0.samples D/Capacitor: Handling local request: http://localhost/assets/icon/favicon.png
2022-12-23 23:42:44.604 7279-7279/com.auth0.samples V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 129665212, pluginId: App, methodName: addListener
2022-12-23 23:42:44.605 7279-7279/com.auth0.samples V/Capacitor: callback: 129665212, pluginId: App, methodName: addListener, methodData: {"eventName":"backButton"}
2022-12-23 23:42:44.605 7279-7336/com.auth0.samples D/Capacitor: Handling local request: http://localhost/node_modules_ionic_core_dist_esm_index-0bc00b33_js.js
2022-12-23 23:42:44.605 7279-7344/com.auth0.samples D/Capacitor: Handling local request: http://localhost/node_modules_ionic_core_dist_esm_status-tap-20472ffa_js.js
<app is loaded, home screen is blank>
<note here is the 60s delay>

2022-12-23 23:43:44.803 7279-7331/com.auth0.samples D/Capacitor: Handling local request: http://localhost/node_modules_ionic_core_dist_esm_ion-button_2_entry_js.js
2022-12-23 23:43:44.806 7279-7344/com.auth0.samples D/Capacitor: Handling local request: http://localhost/assets/icon/favicon.png
2022-12-23 23:43:44.886 7279-7344/com.auth0.samples D/Capacitor: Handling local request: http://localhost/node_modules_ionic_core_dist_esm_ion-ripple-effect_entry_js.js

React support

Currently there is no documentation on how to work with ionic/react + auth0;
There is no good way to support Ionic React project.
Can you please give any advices on how to work with it ( without ionic/enterprise)

There is a plugin which can do some work when you will get into it. But it doesn't support openID
https://github.com/moberwasserlechner/capacitor-oauth2

Please give me some advices. Thank you in advance!

Issue when user token is refreshed

Hi there,

Thank's for this example.

Trying to implement the same logic into my app I ran into an error similar to the one mentioned here: https://community.auth0.com/t/auth0-app-id-doesnt-link-with-the-android-application/67288

Looking into the details, it seems that the error occurs when the id_token is no longer valid, which seems to trigger a "getTokenFromIFrame" function, getting us out of the native "Browser" context causing the app to be stuck on the loading page.

Screenshot 2022-07-04 at 19 56 26

Anyone had a similar error before ?

Edit:

I've found those issues on the auth0 community forum, they seems to face the same issue:

https://community.auth0.com/t/auth0-app-id-doesnt-link-with-the-android-application/67288
https://community.auth0.com/t/silent-authentication-fails-on-capacitor-app-with-error-the-specified-redirect-uri-does-not-have-a-registered-origin/74440

Web Auth without handleRedirectCallback()

I’m baffled.....I’m attempting to use this repo to perform web auth. It works fine, in fact a little too good. I’ve noticed that commenting out the entire ngOnInit() method of app.component leaves the web authentication still functioning properly. How is this possible? handleRedirectCallback is never being called. Please explain the web authentication flow as it relates to this sample code. Thanks so much.

Angular 15, Ionic 7

Is there some example for the latest ionic and angular version using standalone components? I tried to implement it myself but it doesn't work with the public auth: AuthService anymore like in the example, the login and everything works fine and looks good but the
this.auth.isAuthenticated$.subscribe((isAuthenticated) => { console.log(isAuthenticated); });
is always reporting False and the user object is undefined.

Ionic React ios app callback url

I have a web app through ionic that i have setup to work with auth0 and everything works great there but when i have it open through capacitor on ios the callback url isnt working. I changed it to what i thought would be the correct format to match the sample on the quickstart. my app id is: io.app.4155 and the callback url i have been using is: io.app.4155://{domain}/ionic/io.app.4155/callback

onRedirectUri not called

After successful login, I am redirected to the app but the method 'Auth0Cordova.onRedirectUri' never really gets called. Tried passing callback to the Auth's login method and that too never gets called. Below is my code -

$ionicPlatform.ready(function() {
function handleUrl(url) {
console.log('url - ', url');
Auth0Cordova.onRedirectUri(url);
}
window.handleOpenURL = handleUrl;
});

// For the service

function login(callback) {
   var client = new Auth0Cordova(auth0Config);

   var options = {
       scope: 'openid profile offline_access'
   };

   client.authorize(options, function (err, authResult) {
       callback(true);
       if (err) {
           throw new Error(err);
       }
       if (authResult && authResult.accessToken && authResult.idToken) {
           setSession(authResult);
           $rootScope.$apply();
       }
   });

}

Andorid React not authenticated after returning to app

Checklist

  • I have looked into the Readme (React/Angular/Vue) and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

I have downloaded the sample for React and tested using an Android device.

Clicking login correctly loads the Auth0 login page in a browser and after entering credentials the user is taken back to the app, however they're still not authenticated.

Clicking login a second time redirects to auth0 which immediately redirects back to the app, but the app still shows the user as unauthenticated.

Reproduction

  1. Download sample with auth0 account logged in
  2. Add allowed urls to auth0 application settings
  3. Complete npm install etc instructions
  4. Open app in Android Studio and generate app package
  5. Deploy to device (I'm using real devices via lambda test)
  6. Login

Additional context

No response

Sample

React

Platform

Android

Platform version(s)

13

React - Build failure

Good grief guys.......

So I’ve switched to the React app within this repo.
Clone
configure auth.config.ts
npm i
ionic capacitor build ios
yields

react-scripts build
Creating an optimized production build...
Failed to compile.

Module not found: Error: You attempted to import ../../capacitor.config which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.

Are you guys not even testing these repos anymore? I noticed it was just updated yesterday, please attempt to use the provided code.

Login button loops back to login button and does not login

Following the tutorial. When I tap Login, a browser window briefly flashes and it goes back to Login. Tap login again, it just repeats. Happens on both an emulator and a physical phone. I have created a screen recording here. Here is the log file.

Might be a CORS issue? I see the following error in the logs. I don't know how to debug CORS issues and the tutorial doesn't mention them.
2021-11-30 10:08:57.521 5441-5441/com.auth0.samples E/Capacitor/Console: File: http://localhost/home - Line 0 - Msg: Access to XMLHttpRequest at 'https://betterautomations.us.auth0.com/oauth/token' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I am using the following hardware and software:

I had mentioned this problem here but it went away with PR #77. However, it's back again. I re-downloaded the zip file per the instructions in the demo and it includes that PR. I unzipped it and ran the following commands.
npm run build
npx cap sync
npx cap open android

When that didn't work, I tried changing the port to 8100 in src/app/auth.config.ts and in e2e/protractor.conf.js from the default of 4200. Then re-ran build/sync/open. Angular uses 4200 but Ionic uses 8100. Nonetheless, it did not help. Here is the log file from my attempt while using the Pixel 5 emulator.

Here are the settings in my application:
Application Type:
Native

Token Endpoint Authentication Method:
None

Application Login URI:
(Empty)

Allowed Callback URLs:
com.auth0.samples://betterautomations.us.auth0.com/capacitor/com.auth0.samples/callback, com.securecoop.app://betterautomations.us.auth0.com/capacitor/com.securecoop.app/callback, http://localhost:8100

Allowed Logout URLs:
com.auth0.samples://betterautomations.us.auth0.com/capacitor/com.auth0.samples/callback, com.securecoop.app://betterautomations.us.auth0.com/capacitor/com.securecoop.app/callback, http://localhost:8100

Allowed Web Origins:
capacitor://localhost, http://localhost

Allowed Origins (CORS):
(Empty)

Connections:
Username-Password-Authentication
google-oauth2

getTokenSilently results in login_required when requesting access token for second audience

Hello,

This may be similar to issue #235.

Using this sample repo, we were able to successfully authenticate to our app in an iOS emulator, however, we are having some trouble after the initial login. Initially, we have our module configuration passing an audience. In our case, we are using the angular SDK's AuthHttpInterceptor (https://github.com/auth0/auth0-angular/blob/master/projects/auth0-angular/src/lib/auth.interceptor.ts) to retrieve a second access token for a different target audience shortly after the initial login. Upon doing so, we get the generic error from Auth0 - login_required. This works when using the web platform. Checked configurations in Auth0 and everything seems okay there. I saw some potential issues (not sure if its true or not) with the getTokenSilently methods fallback method of using an iframe when using capacitor so we also enabled/tried refresh tokens as well. Same result there. The most interesting this to me is that the silent auth failure in Auth0 doesn't have any user context attached even though the user$ observable is emitting. Perhaps it is a prompt=none, interactive consent required issue?

The API call requiring the second access token is done after the user$ observable emits:

this.authService.user$.pipe(
      takeUntil(this.stopSubscriptions$),
      filter(u => u !== null),
      take(1))
      .subscribe((user) => {
        this.doMoreAfterLogin(user);
      });

Here is the module configuration:

AuthModule.forRoot({
      domain: environment.auth0.domain,
      clientId: environment.auth0.clientId,
      audience: 'urn:api:v2',
      cacheLocation: 'localstorage',
      httpInterceptor: {
        allowedList: [
          {
            uri: 'https://someuriacceptingv1audience/*',
            tokenOptions: {
              audience: urn:api:v1'
            }
          },
          'https://someuriacceptingv2audience/*'
        ]
      },
      redirectUri: redirectUri
    })

Our usage of the 'appUrlOpen' listener is the same as in the sample. Any help you could provide would be greatly appreciated.

android popup mode

On android device when i'm tried to login with social provider i've got infinite loading screen. Probably problem in using popup mode.
screenshot_2016-08-24-21-14-46-312

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.