Skip to content
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
Closed

Retrofit Parameterized Headers #316

jpotts18 opened this issue Aug 28, 2013 · 2 comments

Comments

@jpotts18
Copy link
Contributor

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
Copy link
Collaborator

Can you pass them in at Runtime?

Yes. It works exactly as you outlined.

@JakeWharton
Copy link
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants