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

Authorize a whole service and anonymous methods support #55

Closed
juanpmarin opened this issue Aug 15, 2017 · 1 comment
Closed

Authorize a whole service and anonymous methods support #55

juanpmarin opened this issue Aug 15, 2017 · 1 comment
Labels

Comments

@juanpmarin
Copy link

Hi, great library !

I think that would be useful if I could annotate a service as authorized and mark the unauthorized methods as anonymous, It would be possible ?

Thanks

@andretietz
Copy link
Owner

andretietz commented Aug 20, 2017

I thought about this too, but decided against it. Because you could have one endpoint using different tokens (usertoken, admintoken i.e.). If you would put it on the interface itself, this wouldn't work anymore.

What you can do to simplify your code is:

Implement your own TokenTypeFactory:

MyTokenFactory implements TokenTypeFactory<AndroidTokenType>

and use it in your own implementation of the AuthenticationHandler (pretty simple to implement, see: AndroidAuthenticationHandler)

This way you can tell your TokenTypeFactory what types to use and forget about them in the annotations.

so you can use them like this:

interface Foo {
    @Authenticated
    @GET(...)
    Call<Response> someCall();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants