New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrofit Parameterized Headers #316

Closed
jpotts18 opened this Issue Aug 28, 2013 · 2 comments

Comments

2 participants
@jpotts18
Copy link
Contributor

jpotts18 commented Aug 28, 2013

I am using OAuth and I need to put the OAuth token and API version in my header every time I make a request. I see the @Header annotation, but is there a way to make them dynamic?

Here is the concept...

@Headers({Authorization:'OAuth {var}', X-Api-Version={var} })

Can you pass them in at Runtime?

@GET("/users")
void getUsers(
    @Header("Authorization") String auth, 
    @Header("X-Api-Version") String version, 
    Callback<User> callback
)

I think this could be added to the documentation on the website. I would be happy to add it after I understand the correct implementation. Thanks!

@JakeWharton

This comment has been minimized.

Copy link
Collaborator

JakeWharton commented Aug 28, 2013

Can you pass them in at Runtime?

Yes. It works exactly as you outlined.

@JakeWharton

This comment has been minimized.

Copy link
Collaborator

JakeWharton commented Aug 28, 2013

You can also use a RequestInterceptor passed to the RestAdapter.Builder.

jpotts18 added a commit to jpotts18/retrofit that referenced this issue Aug 28, 2013

@JakeWharton JakeWharton closed this Sep 3, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment