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

HMAC support #429

Closed
artkoenig opened this issue Mar 6, 2014 · 9 comments
Closed

HMAC support #429

artkoenig opened this issue Mar 6, 2014 · 9 comments

Comments

@artkoenig
Copy link

Hi,

I would like to add an HMAC of the URL and request body to the request. The idea was to use a RequestInterceptor to do this. But it does not provide the access to the URL and body. Any ideas how to get this working?

Cheers,
Artjom

@figueredo
Copy link

I managed to get the URL of the request by creating a custom client (subclass ApacheClient and override execute() and you'll have access to a Request object) and using it to build the RestAdapter (see RestAdapter.Builder's setClient()).

It is a pity that it is not possible to get the URL with the RequestInterceptor...

@intrications
Copy link

Similar to @figueredo, I solved this by creating a SigningClient that implements retrofit.client.Client and wraps my OkClient.

The request object in execute(Request request) gives you access to the URL and body.

@artkoenig
Copy link
Author

Thank you very much!

@spiritinlife
Copy link

Thank you for your suggestion @intrications . Based on your idea i have some working code implementing this.You can check it here http://spiritinlife.github.io/android/2014/11/27/Retrofit-HMAC-A-Good-way/ .

@loeschg
Copy link

loeschg commented Dec 2, 2014

Just curious, when you modify the url via a custom client, the RetrofitError (resulting from the request... should there be an error obviously) will return an "outdated" URL, right? Is there any way around this?

@mdrabic
Copy link

mdrabic commented Jan 19, 2015

Okhttp 2.2 has built in support for intercepting and modifying the request before it is sent . I found it possible to achieve this solution using the Interceptors.

@loeschg
Copy link

loeschg commented Jan 19, 2015

@mdrabic yep, just started using that recently. Thanks!

@bjconlan
Copy link

bjconlan commented Feb 1, 2015

This functionality would be possible without knowing the underlying httpClient if the RequestInterceptor.RequestFacade provided some read functionality... mostly just the current state of the url.

Personally I just want the current url string of the request as an exposed function in the facade.

@JakeWharton
Copy link
Member

Use an interceptor in OkHttp. This will not be supported in Retrofit.

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

8 participants