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

Authorization: Moving from StaticTokenAuth to StandardAuth #233

Open
LennyHoglund opened this issue Feb 17, 2022 · 8 comments
Open

Authorization: Moving from StaticTokenAuth to StandardAuth #233

LennyHoglund opened this issue Feb 17, 2022 · 8 comments

Comments

@LennyHoglund
Copy link

We have upgraded to Fortnox SDK 4.3.0. After quite a lot of "plumbing" we have finally got the async version to work. However, a remaining issue is to use the StandardAuth instead of StaticTokenAuth. We have tried to use your examples but we can not make them to work. Please give use some basic instrucktions how we can achive this using c# in a Web pages project.

Thanks,
Lennart Hoglund

@richardrandak
Copy link
Collaborator

Can you tell me a little more about what was the problem with using the async version?

By Web pages do you mean the Razor pages in ASP.NET Core?
Can you tell me what problem are you stuck at? Is there some error you can't resolve?

@LennyHoglund
Copy link
Author

LennyHoglund commented Feb 17, 2022 via email

@richardrandak
Copy link
Collaborator

Hi Lennart!
First of all, the access token used in the old auth won't work with the new auth.
Getting an access token in the new auth requires a user interaction, specifically, redirecting him to an fortnox auth uri, handling a callback in your app and managing the token life span.
I assume you have read the wiki right? https://github.com/FortnoxAB/csharp-api-sdk/wiki/FortnoxAuth

One more thing.. did you consider whether need to switch to the new workflow? Are there new users using your app ?

@LennyHoglund
Copy link
Author

LennyHoglund commented Feb 17, 2022 via email

@richardrandak
Copy link
Collaborator

You're welcome. Unfortunetely, I don't have resources to advise you regarding the app design for the new workflow, so I hope the wiki provides enough information. It is a basically a common OAuth2 workflow, which requires redirecting a user to Fortnox auth server and handling the callback with an authorization code, which is then exchanged for access token in your app.

I will be glad to hear about your progress.

@LennyHoglund
Copy link
Author

LennyHoglund commented Feb 22, 2022 via email

@richardrandak
Copy link
Collaborator

richardrandak commented Feb 22, 2022

The function takes collection of scopes. If you need just one, just make an array out of it

var fortnoxAuthClient = new FortnoxAuthClient;
var authWorkflow = fortnoxAuthClient.StandardAuthWorkflow;
var authUri = authWorkflow.BuildAuthUri(ClientId, new [] { Scope.Customer }, state);

@LennyHoglund
Copy link
Author

LennyHoglund commented Feb 22, 2022 via email

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

2 participants