Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8794395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:14:43+00:00 2026-06-13T23:14:43+00:00

I am trying to add some custom header parameters to a HTTP 303 (redirect)

  • 0

I am trying to add some custom header parameters to a HTTP 303 (redirect) response. However, the new headers seem to be getting stripped from the response.

This code is meant to receive a request and returns a HTTP 303 response:

@POST
@Path("/authorize")
@Produces("application/x-www-form-urlencoded")
public Response getOAuthGrant(@HeaderParam(OAuth2.AUTHORIZATION)    @DefaultValue("") String authorization,
                              @HeaderParam(OAuth2.CLIENT_ID)        @DefaultValue("") String clientId,
                              @HeaderParam(OAuth2.CLIENT_SECRET)    @DefaultValue("") String clientSecret,
                              @HeaderParam(OAuth2.GRANT_TYPE)       @DefaultValue("") String grantType) throws InternalServerException, UnauthorizedException {

        OAuth2.validateGrantRequest(clientId, clientSecret, authorization, grantType);

        ApiTokenV2 apiTokenV2 = new ApiTokenV2();

        try {
            apiTokenV2 = TokenManager.getApiToken(clientId);

            if (apiTokenV2 != null) {
                apiTokenV2.generateAccessGrant(clientId);
            } else {
                logger.error("Error in TokenEndpoint. Retrieved token is null.");
                throw new InternalServerException("A server error occurred while trying to authorize the requester. Could not find 'generateAccessGrant' method");
            } 
        } catch (NamingException e) {
            throw new InternalServerException("A server error occurred while trying to authorize grant request. Could not find 'generateAccessGrant' method.", e);
        }

        return Response.status(Response.Status.SEE_OTHER)
                       .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
                       .header("Location", "/api/token")
                       .header("Authorization", "OAuth")
                       .header("Access-Grant", apiTokenV2.getAccessGrant())
                       .build();
}

What am I doing wrong here? Should I be using @Context instead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:14:44+00:00Added an answer on June 13, 2026 at 11:14 pm

    What you are trying to do should work.

    @POST
    @Path("/authorize")
    public Response authorize() {
        return Response.status(Response.Status.SEE_OTHER)
                .header(HttpHeaders.LOCATION, "/api/token")
                .header("X-Foo", "bar")
                .build();
    }
    

    Executing it with curl:

    % curl -v -X POST http://localhost:8080/WebApplication1/rest/console/authorize
    * About to connect() to localhost port 8080 (#0)
    *   Trying ::1... connected
    > POST /WebApplication1/rest/console/authorize HTTP/1.1
    > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
    > Host: localhost:8080
    > Accept: */*
    > 
    < HTTP/1.1 303 See Other
    < X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
    < Server: GlassFish Server Open Source Edition 3.1.2.2
    < Location: /api/token
    < X-Foo: bar
    < Content-Length: 0
    < Date: Wed, 07 Nov 2012 08:20:24 GMT
    < 
    * Connection #0 to host localhost left intact
    * Closing connection #0
    

    As you can see, the response code is

    303 See Other
    

    and the interesing headers are set:

    Location: /api/token
    X-Foo: bar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add some custom filter methods to my magento module. I though
I am new to JQuery. I am trying to add some code in my
I'm trying to add some custom data within a tag to reference later in
I am trying to add some custom functionality to the MUI2 Components Page. When
I am trying to add some custom QGraphicsItems in a QGraphicsScene on mouse click
I have a custom view, extending LinearLayout and im trying to add some custom
I am trying to add some custom build steps to my headless build process
I'm trying to derive from the Silverlight Panel control to add some custom logic
I'm getting: java.io.IOException: Invalid header signature; read 0x000201060000FFFE, expected 0xE11AB1A1E011CFD0 when trying to add
i'm trying to add some custom attributes to the checkout(sales) page of magento 1.5.1.0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.