question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use the SDK with an "App Token" (Server Authentication)?

See original GitHub issue

We’re writing an app that needs to be able to upload files to Box so that we can use the “New Box View” preview functionality. I’ve created an app in the Box dev console, and specified “App Token (Server Authentication)” as the authentication type, as specified by the migration docs.

Looking at the SDK readme for .NET and I’m having a heck of a time trying to decipher how the “App Token” style of authentication jives with what’s in the readme. In the readme I see terminology like “Client Id”, “Client Secret”, “Developer Token,” etc. But in the new app I’ve created, the terminology is “API Key”, “Primary Access Token”, “Secondary Access Token” (which I understand is just a fallback that works like the primary).

So when I see this example of how to setup a client, I don’t really understand how to utilize the key/token that has been generated:

var config = new BoxConfig(<Client_Id>, <Client_Secret>, new Uri("http://localhost"));
var session = new OAuthSession(<Developer_Token>, "NOT_NEEDED", 3600, "bearer");
client = new BoxClient(config, session);

Does anyone have an example of how to use the SDK with the App Token (Server Authentication)?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mattwillercommented, Jan 5, 2018

Hey @winzig — the example linked is for JWT Auth, not the App Token Auth your app is using. In order to use the App Token you have, you’d want to do something like this:

var config = new BoxConfig(<YOUR API KEY>, "", new Uri("http://localhost"));
var session = new OAuthSession(<YOUR PRIMARY/SECONDARY TOKEN>, "NOT_NEEDED", 3600, "bearer");
var client = new BoxClient(config, session);

// Get the items in the account's root folder
var items = await client.FoldersManager.GetFolderItemsAsync("0", 500);

Can you give that a try and see if it works for you?

0reactions
mattwillercommented, Jan 5, 2018

@winzig Great, I’m glad it’s working for you! 🎉 We’ll add some documentation to help clarify how to use the different auth models.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setup with App Token Auth
To configure an app token, navigate to the Configuration tab for your application within the Developer Console. Scroll down to the Primary Access...
Read more >
How to use sdk with App Token (Server Authentication)?
Hey @ovvn — if you're using App Token auth, you already have a valid access token, so you can just do var client...
Read more >
Token Based Authentication Made Easy
The simplest way to do this is to use an app like Postman which simplifies API endpoint testing. When making the call add...
Read more >
Using OAuth 2.0 for Server to Server Applications
Then, your application prepares to make authorized API calls by using the service account's credentials to request an access token from the OAuth...
Read more >
SDK Authentication
SDK Authentication allows you to supply cryptographic proof (generated server-side) to SDK requests made on behalf of logged-in users.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found