capacitor-community / generic-oauth2

Generic Capacitor OAuth 2 client plugin. Stop the war in Ukraine!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ionic Angular Capacitor - Please help how to implement Refresh Token in HTTP Interceptor

xzetic opened this issue · comments

Description

Is there a way to implement that OAuth2Client.refreshToken returning as promise into Angular HttpInterceptor where it will auto refresh the token when we received an API status reply of 401.
The framework is Angular. Thank you!

Capacitor version:

Run npx cap doctor:

Installed Dependencies:
@capacitor/core: 3.4.3
@capacitor/cli: 3.4.3
@capacitor/android: 3.4.3
@capacitor/ios: 3.4.3

Library version:

  • 3.0.1

OAuth Provider:

  • Azure AAD

Your Plugin Configuration

{
    // Replace this with your plugin configuration
}

Affected Platform(s):

  • Android
    • Version/API Level: 29
    • Device Model: Samsung Galaxy S21 Ultra
    • Content of your AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
        android:name="com.accenture.global.myte.MainActivity"
        android:label="@string/title_activity_main"
        android:theme="@style/AppTheme.NoActionBarLaunch"
        android:launchMode="singleTask">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <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="msauth://"/>
        </intent-filter>

    </activity>

    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths"></meta-data>
    </provider>
</application>

<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Camera, Photos, input file -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Geolocation API -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<!-- Network API -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Video -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Audio -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> -->
``` * iOS * Version/API Level: 12 * Device Model: iPhone 13 Pro * Content of your `Info.plist` ```xml CFBundleDevelopmentRegion en CFBundleDisplayName MyTimeAndExpenses CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 14.3.0 CFBundleVersion 3 LSRequiresIPhoneOS NSAppTransportSecurity NSAllowsArbitraryLoads UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance NSCameraUsageDescription Privacy - Camera Usage Description NSPhotoLibraryAddUsageDescription Privacy - Photo Library Additions Usage Description NSPhotoLibraryUsageDescription Privacy - Photo Library Usage Description NSLocationAlwaysUsageDescription Privacy - Location Always Usage Description NSLocationWhenInUseUsageDescription Privacy - Location When In Use Usage Description CFBundleURLTypes CFBundleURLSchemes msauth.com.accenture.global.myte ``` * Web * Browser: Edge