Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using StandardAuth for backend automations without user interaction #262

Open
keenfann opened this issue Nov 25, 2022 · 6 comments
Open

Comments

@keenfann
Copy link

We have various integrations that interact with Fortnox where we automatically get/create/update invoices, customers, contracts and other entities. These integrations are executed in our integrations solution without user interaction.

We are currently using StaticTokenAuth but since this is deprecated, and the StandardAuth flow requires a user to interactively sign in, what are the guidelines for our scenario? I cannot find a /login endpoint or similar where our application can get a token that we can use in subsequent requests.

@richardrandak
Copy link
Collaborator

Hello! As far as I know, the only way to have automated integrations is to handle token refresh periodically. The initial setup must be done interactively.
So, one time setup with user and then automated connection by using refresh token to keep it alive.

@keenfann
Copy link
Author

Thanks for the response!

The method you're suggesting feels kinda unusual, would it be possible for you post an example in the readme or a sample project for this flow?

@sblomstrand
Copy link

This does not feel like a viable solution in server-to-server scenarios.
Is there not a client credentials flow to retrieve auth-tokens using clientId and clientSecret?

@xpagedeveloper
Copy link

The new Auth flow is that you always need start with a user interaction and authorization.
After that you have an auth token and a refresh token. The refresh token is used to get a new auth token and a new refreshtoken.
You need to do this refresh at least with a 30 day interval, I use 20 days in our applications.
You will need to have some kind of single thread update function so you don't loose or mixup the refreshtoken because if you do. You will need to restart the initial auth flow with a user involved.

@sblomstrand
Copy link

That would work if there is only one application accessing the token. In a distributed environment where several applications access the same token and simultaneously need to refresh that token we would need to implement a distributed lock on the refresh in order to not have a race condition. Or am i mistaken?

@mohsin-patel
Copy link

mohsin-patel commented Jan 18, 2024

What will happen if refresh token expired some how due to system refresh routine failure. The end-user will see login prompt and end user enter their credentials and whole system start with new token generated by end user credentials :)

I think Authorization code flow is good for client centric integrations. you people should enable other types of integrations flow so, other people can use just use one account for generating invoices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants