Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Manjit S.'s avatar
Manjit S.
New member | Level 1
10 years ago

The request was redirected

I am using angularJs with webapi and now i want to upload a file on dropbox after login in my webproject on click of a upload button.I have made an api to go the login page of dropbox and after login i want to redirect it to my own page again by redirect url.But when i am calling the webapi its giving the correct url but not redirection to the DropBox page and showing XMLHttpRequest cannot load http://localhost:3371/api/accounts/ConnectDropDown. The request was redirected to 'https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id=m5e…2F%2Flocalhost%3A3371%2FHome%2FAuth&state=f50e71f99dc54e0da547d85ffbbd4764', which is disallowed for cross-origin requests that require preflight. in the console of the browser.

 

AngularJs:
var _connectDropbox = function () {
$http.defaults.useXDomain = true;
delete $http.defaults.headers.common['X-Requested-With'];
return $http.get(serviceBase + 'api/accounts/ConnectDropDown').then(function (results) {
return results;
});
};


[Route("ConnectDropDown")]
public async Task<HttpResponseMessage> ConnectDropDown()
{
var username = User.Identity.Name;
var user = await this.AppUserManager.FindByNameAsync(username);
var appKey = ConfigurationManager.AppSettings["DropboxAppKey"];
var appSecret = ConfigurationManager.AppSettings["DropboxAppSecret"];
var ConnectState = Guid.NewGuid().ToString("N");
user.ConnectState = ConnectState;
IdentityResult addUserResult = await this.AppUserManager.UpdateAsync(user);          
var redirect = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Code, appKey,RedirectUri,ConnectState);
var response = Request.CreateResponse(HttpStatusCode.Moved);
response.Headers.Location = redirect;
return response;
}
 

 

1 Reply

Replies have been turned off for this discussion

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!