Skip to content

[Help Wanted]: Token expire location sending to server most of error returns 401 sometime hits 500 error #2440

@FazilMuhammed299

Description

@FazilMuhammed299

Required Reading

  • Confirmed

Plugin Version

4.19.3

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

Oneplus,Samsung

Device operating-systems(s)

18.1

React Native / Expo version

0.81.1

What do you require assistance about?

if token expire our background location API is frequently returning 401 error responses and occasionally 500 errors. Is there a way to trigger the refresh token URL automatically when a 500 error occurs

[Optional] Plugin Code and/or Config

let configDefault = {
    disableMotionActivityUpdates: false,
    activityRecognitionInterval: 30000,
    motionTriggerDelay: 0,
    useSignificantChangesOnly: false,

    stopAfterElapsedMinutes: Boolean(end_of_tracking)
      ? stopAfterElapsedMinutes
      : 720,
    stopTimeout: 5,

    distanceFilter: 50,
    desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION,
    desiredOdometerAccuracy: 100,
    stationaryRadius: 25,

    disableElasticity: true,

    foregroundService: true,
    notification: {
      title: 'Live tracking enabled',
      text: 'Location service activated',
      smallIcon: 'drawable/ic_stat_onesignal_default',
      priority: BackgroundGeolocation.NOTIFICATION_PRIORITY_HIGH,
      sticky: true,
    },

    isMoving: true,
    debug: false,
    logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
    disableProviderChangeRecord: true,
    locationAuthorizationRequest: 'Always',
    backgroundPermissionRationale: {
      title: 'Background Location Access',
      message:
        'As per the configurations, you need to enable the background location for the check-in/out. You can enable it by selecting {backgroundPermissionOptionLabel} from the location permission',
      positiveAction: 'Change to {backgroundPermissionOptionLabel}',
      negativeAction: 'Cancel',
    },

    maxDaysToPersist: 1,
    stopOnTerminate: false,
    startOnBoot: true,
    enableHeadless: true,
    preventSuspend: true,

    url: `${endpoint}/geolocation/api/v2/real-time-tracking/`,
    headers: {
      Accept: 'application/json',
      'X-DTS-SCHEMA': `https://${domain}`,
    },
    autoSync: true,
    locationsOrderDirection: 'ASC',
    
    params: {
      employeeId: id,
      employeeCode: empCode,
      appVersion: appVersion,
      buildNumber: buildNumber,
      bundleId: bundleId,
      deviceName: deviceName,
      deviceId: deviceId,
      deviceModel: model,
      deviceBrand: brand,
      manufacturer: manufacturer,
      uniqueDeviceId: uniqueId,
      platform: systemName,
      osVersion: systemVersion,
      domain: domain,
    },

    authorization: {
      strategy: 'JWT',
      accessToken: token,
      refreshToken: refreshToken,
      refreshUrl: `${endpoint}/api/token/refresh-with-expiry/`,
      refreshPayload: {
        refresh: '{refreshToken}',
      },
      refreshHeaders: {
        'Content-Type': 'application/json',
        'X-DTS-SCHEMA': `https://${domain}`,
      },
      expires: 3600,
    },

    allowIdenticalLocations: true,
    scheduleUseAlarmManager: true,
  };

[Optional] Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions