Authenticate with QBO#39219
Conversation
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,7 @@ | |||
| type WorkspaceIntegrationImportStatus = { | |||
| status: 'starting' | 'finished' | 'progress'; | |||
There was a problem hiding this comment.
I think you can remove the status and just use stageInProgress
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
|
@hayata-suenaga I see that the |
|
@aldo-expensify, this is the PR that is implementing the After we finish this PP to open the authentication flow, we will create another PR to add to trigger the authentication flow when the button is clicked. |
@hayata-suenaga Did you forget to add the link? :P |
|
oops 😓 🙇 here is the link 😄 |
|
@aldo-expensify, just a heads up. Some codes related to the QBO authentication flow were added in this PR that implements the ex. |
|
Added a constant for the command |
|
Created a follow up issue #40365 for the Desktop bug |
marcaaron
left a comment
There was a problem hiding this comment.
Changes LGTM. Did not have any hard blockers, but left some questions and small improvements. Noted that there are mistakes left in the code, but sounds like @aldo-expensify has plans to follow up and address them.
| Cookie: `authToken=${session?.authToken}`, | ||
| }, | ||
| }} | ||
| incognito // 'incognito' prop required for Android, issue here https://github.com/react-native-webview/react-native-webview/issues/1352 |
There was a problem hiding this comment.
NAB, but this comment suggests we should have a platform implementation where the incognito prop is only passed for Android if we don't need it on other platforms.
There was a problem hiding this comment.
I see what you are saying, but to me the code duplication of adding the index.android.ts is worse. This prop doesn't affect in a negative way for IOS.
There was a problem hiding this comment.
Could we maybe remove the comment about Android?
One downside of leaving platform specific logic in the code is that the many contributors who work on this code will then think it's OK to bend one of our rules.
| [WRITE_COMMANDS.SET_POLICY_DISTANCE_RATES_UNIT]: Parameters.SetPolicyDistanceRatesUnitParams; | ||
| [WRITE_COMMANDS.SET_POLICY_DISTANCE_RATES_DEFAULT_CATEGORY]: Parameters.SetPolicyDistanceRatesDefaultCategoryParams; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any |
There was a problem hiding this comment.
Doesn't look like this was added in this PR but looks related to this project. Why do we need to have any here?
There was a problem hiding this comment.
Ahh this was a problem cause by the generic of the param type here #39219 (comment). We are "forced" to choose something here and any seemed to work good enough.
An alternative would be to define different constants for each combination of <connectionName, settingName>, but that sounds worse I think.
|
|
||
| if (shouldUseStagingServer) { | ||
| if (CONFIG.IS_USING_WEB_PROXY) { | ||
| if (CONFIG.IS_USING_WEB_PROXY && !request?.shouldSkipWebProxy) { |
There was a problem hiding this comment.
suggestion: since we mainly use the proxy to avoid CORS errors and (I presume) there is no problem with CORS errors when using a WebView this could be updated to something like request.isForWebView. That way we are not exposing the underlying "proxy" or "no proxy" to other areas of the code that don't really need to know about it.
and a question - Is it a problem to use the proxy for this? 🤔 If so, can we please add a comment here about why the proxy does not work for webviews?
There was a problem hiding this comment.
since we mainly use the proxy to avoid CORS errors and (I presume) there is no problem with CORS errors when using a WebView this could be updated to something like request.isForWebView.
This problem doesn't only apply to WebViews, it is also there in "web" when the URL opens in a new tab. The URL created when we use the proxy is /CommandName?xxx, it misses the domain, so then the function Link.openLink misses that it needs to get a short lived auth token for it.
There was a problem hiding this comment.
or maybe... requiresShortLivedAuthToken 😬
There was a problem hiding this comment.
yeah, I like that better.
| // { | ||
| // onyxMethod: Onyx.METHOD.MERGE, | ||
| // key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
| // value: { | ||
| // errorFields: { | ||
| // avatar: ErrorUtils.getMicroSecondOnyxError('avatarWithImagePicker.deleteWorkspaceError'), | ||
| // }, | ||
| // }, | ||
| // }, | ||
| ]; |
There was a problem hiding this comment.
Is it going to cause conflicts to delete this? 🤔
| }; | ||
| API.write(WRITE_COMMANDS.REMOVE_POLICY_CONNECTION, parameters, {optimisticData, failureData}); | ||
| } | ||
| function updatePolicyConnectionConfig<TConnectionName extends ConnectionName, TSettingName extends keyof Connections[TConnectionName]['config']>( |
There was a problem hiding this comment.
Did we do too much TypeScript here? 😄
There was a problem hiding this comment.
haha, I though it could cause problems when using the function updatePolicyConnectionConfig, but it didn't and works pretty well on matching the settingName with the possible settingValues for a specific connection name (find some usages of updatePolicyConnectionConfig).
| [settingName]: settingValue, | ||
| pendingFields: { | ||
| [settingName]: null, | ||
| }, | ||
| errorFields: { | ||
| [settingName]: null, | ||
| }, |
Co-authored-by: Marc Glasser <marc@expensify.com>
|
Merged main and resolved conflicts. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
Created another follow up issue for the flashing "Set up" button: |
|
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.4.63-0 🚀
|
We bumped our head too with Xero on this one... Glad you've posted about it here! |
|
@lakchote there are two issues that may impact your work:
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.63-21 🚀
|
cc: @aldo-expensify
Details
This PR is part of the QBO project where we supports integration with QuickBooks Online, an accounting software, on New Expensify.
This PR adds a button that the user can click to start the authentication flow with the QBO. On both web and native platforms, this button opens up a new web page where the user can authenticate with the QBO. After the authentication is complete, the user's authentication token is stored in the backend and the web page closes.
On a web browser, the web page is opened on a separate browser window. On iOS and Android, a temporary browser window is opened as a modal within the app to display the web page.
Fixed Issues
$ #39094
PROPOSAL: N/A
Tests
Important Notes for testing: When testing the QBO authentication flow:
Test on iOS or Android
QA Steps
No QA. The new button is not used yet. There is no way for the QA team to test this.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps./** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
Screen.Recording.2024-04-16.at.5.58.01.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2024-04-10.at.6.13.30.PM.mov
MacOS: Desktop