Skip to content

Commit

Permalink
fix token refresh on ios, update podfile.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel authored and Manuel committed Oct 18, 2023
1 parent 3109b71 commit 2c04ccd
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 13 deletions.
199 changes: 199 additions & 0 deletions ios/App/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
PODS:
- ByteowlsCapacitorOauth2 (5.0.0):
- Capacitor
- OAuthSwift (= 2.2.0)
- Capacitor (5.4.2):
- CapacitorCordova
- CapacitorApp (5.0.6):
- Capacitor
- CapacitorBrowser (5.1.0):
- Capacitor
- CapacitorClipboard (5.0.6):
- Capacitor
- CapacitorCordova (5.4.2)
- CapacitorDevice (5.0.6):
- Capacitor
- CapacitorHaptics (5.0.6):
- Capacitor
- CapacitorKeyboard (5.0.6):
- Capacitor
- CapacitorLocalNotifications (5.0.6):
- Capacitor
- CapacitorNavigationbarnx (0.0.2):
- Capacitor
- CapacitorPreferences (5.0.6):
- Capacitor
- CapacitorPushNotifications (5.1.0):
- Capacitor
- CapacitorSplashScreen (5.0.6):
- Capacitor
- CapacitorStatusBar (5.0.6):
- Capacitor
- CapacitorToast (5.0.6):
- Capacitor
- CordovaPlugins (5.4.2):
- CapacitorCordova
- Firebase/CoreOnly (9.2.0):
- FirebaseCore (= 9.2.0)
- Firebase/Messaging (9.2.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 9.2.0)
- FirebaseCore (9.2.0):
- FirebaseCoreDiagnostics (~> 9.0)
- FirebaseCoreInternal (~> 9.0)
- GoogleUtilities/Environment (~> 7.7)
- GoogleUtilities/Logger (~> 7.7)
- FirebaseCoreDiagnostics (9.2.0):
- GoogleDataTransport (< 10.0.0, >= 9.1.4)
- GoogleUtilities/Environment (~> 7.7)
- GoogleUtilities/Logger (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- FirebaseCoreInternal (9.2.0):
- "GoogleUtilities/NSData+zlib (~> 7.7)"
- FirebaseInstallations (9.2.0):
- FirebaseCore (~> 9.0)
- GoogleUtilities/Environment (~> 7.7)
- GoogleUtilities/UserDefaults (~> 7.7)
- PromisesObjC (~> 2.1)
- FirebaseMessaging (9.2.0):
- FirebaseCore (~> 9.0)
- FirebaseInstallations (~> 9.0)
- GoogleDataTransport (< 10.0.0, >= 9.1.4)
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
- GoogleUtilities/Environment (~> 7.7)
- GoogleUtilities/Reachability (~> 7.7)
- GoogleUtilities/UserDefaults (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleDataTransport (9.1.4):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/AppDelegateSwizzler (7.7.0):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.7.0):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.7.0):
- GoogleUtilities/Environment
- GoogleUtilities/Network (7.7.0):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.7.0)"
- GoogleUtilities/Reachability (7.7.0):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (7.7.0):
- GoogleUtilities/Logger
- nanopb (2.30909.0):
- nanopb/decode (= 2.30909.0)
- nanopb/encode (= 2.30909.0)
- nanopb/decode (2.30909.0)
- nanopb/encode (2.30909.0)
- OAuthSwift (2.2.0)
- PromisesObjC (2.1.1)

DEPENDENCIES:
- "ByteowlsCapacitorOauth2 (from `../../node_modules/@byteowls/capacitor-oauth2`)"
- "Capacitor (from `../../node_modules/@capacitor/ios`)"
- "CapacitorApp (from `../../node_modules/@capacitor/app`)"
- "CapacitorBrowser (from `../../node_modules/@capacitor/browser`)"
- "CapacitorClipboard (from `../../node_modules/@capacitor/clipboard`)"
- "CapacitorCordova (from `../../node_modules/@capacitor/ios`)"
- "CapacitorDevice (from `../../node_modules/@capacitor/device`)"
- "CapacitorHaptics (from `../../node_modules/@capacitor/haptics`)"
- "CapacitorKeyboard (from `../../node_modules/@capacitor/keyboard`)"
- "CapacitorLocalNotifications (from `../../node_modules/@capacitor/local-notifications`)"
- CapacitorNavigationbarnx (from `../../node_modules/capacitor-navigationbarnx`)
- "CapacitorPreferences (from `../../node_modules/@capacitor/preferences`)"
- "CapacitorPushNotifications (from `../../node_modules/@capacitor/push-notifications`)"
- "CapacitorSplashScreen (from `../../node_modules/@capacitor/splash-screen`)"
- "CapacitorStatusBar (from `../../node_modules/@capacitor/status-bar`)"
- "CapacitorToast (from `../../node_modules/@capacitor/toast`)"
- CordovaPlugins (from `../capacitor-cordova-ios-plugins`)
- Firebase/Messaging
- FirebaseCore

SPEC REPOS:
trunk:
- Firebase
- FirebaseCore
- FirebaseCoreDiagnostics
- FirebaseCoreInternal
- FirebaseInstallations
- FirebaseMessaging
- GoogleDataTransport
- GoogleUtilities
- nanopb
- OAuthSwift
- PromisesObjC

EXTERNAL SOURCES:
ByteowlsCapacitorOauth2:
:path: "../../node_modules/@byteowls/capacitor-oauth2"
Capacitor:
:path: "../../node_modules/@capacitor/ios"
CapacitorApp:
:path: "../../node_modules/@capacitor/app"
CapacitorBrowser:
:path: "../../node_modules/@capacitor/browser"
CapacitorClipboard:
:path: "../../node_modules/@capacitor/clipboard"
CapacitorCordova:
:path: "../../node_modules/@capacitor/ios"
CapacitorDevice:
:path: "../../node_modules/@capacitor/device"
CapacitorHaptics:
:path: "../../node_modules/@capacitor/haptics"
CapacitorKeyboard:
:path: "../../node_modules/@capacitor/keyboard"
CapacitorLocalNotifications:
:path: "../../node_modules/@capacitor/local-notifications"
CapacitorNavigationbarnx:
:path: "../../node_modules/capacitor-navigationbarnx"
CapacitorPreferences:
:path: "../../node_modules/@capacitor/preferences"
CapacitorPushNotifications:
:path: "../../node_modules/@capacitor/push-notifications"
CapacitorSplashScreen:
:path: "../../node_modules/@capacitor/splash-screen"
CapacitorStatusBar:
:path: "../../node_modules/@capacitor/status-bar"
CapacitorToast:
:path: "../../node_modules/@capacitor/toast"
CordovaPlugins:
:path: "../capacitor-cordova-ios-plugins"

SPEC CHECKSUMS:
ByteowlsCapacitorOauth2: dde6b8fdf2995bc7872434c407ee2492ce562638
Capacitor: 8a9db42d105f55843cd8ed2a3cb54e2b78e7f102
CapacitorApp: 963d90cb449803d58efc33bb515c81151e69159d
CapacitorBrowser: 31371ef981e378cb592be8cc203a9a4cbf43c486
CapacitorClipboard: ae6864d6b4ff2243fc7ce19124df307d8d1bb78d
CapacitorCordova: cfcc06b698481da655415985eeb2b8da363f8451
CapacitorDevice: 9233ba5f0c8f601bf4992006f5d2b2a86b7abc2e
CapacitorHaptics: 186982679c5f4005d1e6d2c719b8251c0d3a6df8
CapacitorKeyboard: 2f3296af2bc929a5069f02ed264fdce58ed62028
CapacitorLocalNotifications: 7ed607db672dc2834f22a25422b86e74129a032a
CapacitorNavigationbarnx: a22badd7d90d9715ecc08f3ae3824a57a37724b0
CapacitorPreferences: 8053abfef3bd11e3e83834792a97e5a6387bf591
CapacitorPushNotifications: 14425a66891d4134e73b6abe1932eeff37e4389d
CapacitorSplashScreen: f3c7de5468a52893e90f49d033772984270241b4
CapacitorStatusBar: a73a9ae0dd2ca30ee429782d5d3ae82dcfa80207
CapacitorToast: 61a9bec819ad3aeccc1ebe3fcbff565c22969c71
CordovaPlugins: 13d1f5b0b81c2eba67b8f70432c3edb07483877c
Firebase: 4ba896cb8e5105d4b9e247e1c1b6222b548df55a
FirebaseCore: 0e27f2a15d8f7b7ef11e7d93e23b1cbab55d748c
FirebaseCoreDiagnostics: ad3f6c68b7c5b63b7cf15b0785d7137f05f32268
FirebaseCoreInternal: cb966328b6985dbd6f535e1461291063e1c4a00f
FirebaseInstallations: 21186f0ca7849f90f4a3219fa31a5eca2e30f113
FirebaseMessaging: 4eaf1b8a7464b2c5e619ad66e9b20ee3e3206b24
GoogleDataTransport: 5fffe35792f8b96ec8d6775f5eccd83c998d5a3b
GoogleUtilities: e0913149f6b0625b553d70dae12b49fc62914fd1
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
OAuthSwift: 75efbb5bd9a4b2b71a37bd7e986bf3f55ddd54c6
PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb

PODFILE CHECKSUM: 0abccb83d0d503da1628c7d1ca5579739161bb33

COCOAPODS: 1.10.2
7 changes: 7 additions & 0 deletions src/app/requests/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,13 @@ export class RefreshTokenRequest extends APIRequest<ApiTokenResponse> {
requiresAuth = true
ignoreFails = true
maxCacheAge = 1000
options = {
url: null,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/json',
},
}

parse(response: Response): ApiTokenResponse[] {
if (response && response.data) return [response.data] as ApiTokenResponse[]
Expand Down
16 changes: 3 additions & 13 deletions src/app/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,9 @@ export class ApiService extends CacheModule {

const now = Date.now()
const req = new RefreshTokenRequest(user.refreshToken)

const formBody = new FormData()
formBody.set('grant_type', 'refresh_token')
formBody.set('refresh_token', user.refreshToken)
const url = await this.getResourceUrl(req.resource, req.endPoint)

// use js here for the request since the native http plugin performs inconsistent across platforms with non json requests
const resp = await fetch(url, {
method: 'POST',
body: formBody,
headers: await this.getAuthHeader(true),
})
const result = await resp.json()
const resp = await this.execute(req)
const response = req.parse(resp)
const result = response[0]

console.log('Refresh token', result, resp)
if (!result || !result.access_token) {
Expand Down

0 comments on commit 2c04ccd

Please sign in to comment.