Reputation: 23
I got "As-User" header enabled with our enterprise admin account with Box.com to impersonate other users and trying to use the previously generated token without refreshing/regenerating every time. When I am trying to connect Box.com thru my vb.net code, getting "Box returned HTTP Code Unauthorized (Unauthorized): " error. What I am doing wrong? Do i need to write any extra code?
Do I need to compare the token generated file creation date with today's date for less than 60 days, in order to refresh/regenerate the token before it expires?
'''' Reading Refresh token from the file Dim streamReader As StreamReader streamReader = System.IO.File.OpenText(Server.MapPath("~\Box\BoxApiRefreshToken.txt")) oldRefreshToken = streamReader.ReadToEnd() streamReader.Close()
boxManager = New BoxManager(oldRefreshToken)
Upvotes: 1
Views: 494
Reputation: 51
Once you apply a new scope to your API key you have to walk through the manual OAuth process again for that scope to apply to your access token. Try logging in again through OAuth, generate a new access/refresh token pair, then attempt to make your request with the As-User header.
Keep in mind co-admins cannot attempt to make API requests as other co-admins or the primary admin.
Upvotes: 1