Skip to content

Retrofit Parameterized Headers #316

Closed
@jpotts18

Description

@jpotts18

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions