How to programmatically retrieve auth code from V2 API
回答済みHi All,
When I'm trying to retrieve an auth code to enter into any given request I am trying to make of the API I always have to authorize myself manually to retrieve an auth code via a browser and then copy the auth code into my code to continue my development. I have seen no examples of programmatically doing this through code. I would love to be able to authorize programmatically and I am sure this is possible.
-
Once you generate access/refresh tokens, you can keep them in a token store. When you establish a new Box client session, you'll get a new token pair that you can store for the next time. The refresh token is good for 60 days, so as long as you're using it at least once every two months, that would be an option.
That said, the approach doesnj't work well if you have multiple instances of the application running concurrently. They'll step on each other and invalidate the tokens pretty quickly.
So you may want to take a closer look at Service Accounts (formerly called Enterprise users). There's no application-size token management required. You authorize your application in the Box admin console and provide the public key and you're good to go. Depending on what language/SDK you're using, there should be examples of this. I have some Node.js setup steps I can share if that would help.
サインインしてコメントを残してください。
コメント
1件のコメント