I can't understand how to make OAuth 1.0 POST request using Retrofit library in Android.
This is the OAuth 1.0 Post request which I made in Postman
Help please, I can not understand how to transfer data such as consumer key, consumer secret, callbakurl to the request method, I think it is not supposed to be by annotations such as #Header or #Query. Also, I do not understand how to indicate in the request method that it is OAuth 1.0 and also that it is Authorization.
And also I get a response in the URL format. How can I get the response in the JSON format?
Thank you
Related
Can't get past Django Rest Framework Token Authorization because I can't set withCredentials=true using OkHttp RequestBuilder. (I'm referring to this https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials)
In javascript using axios.post this works fine. I'm having trouble converting this post request to android using OkHttp request builder.
Request builder only seems to give setter methods for Header and Body of post Request?
Tried reading through OkHttp documentation and I've also tried to send withCredentials=True as a header
Django Rest Framework backend not recognizing the token and not resolving the bearer token to a user.
If no class authenticates, request.user will be set to an instance > of django.contrib.auth.models.AnonymousUser, and request.auth > will be set to None.
I'm going to assume here that withCredentials is a query parameter.
Appending ?withCredentials=true. to the end of the URL will probably get things going for you.
An example in full might look like https://www.example.com?withCredentials=true.
With multiple parameters, it may look like https://www.example.com?withCredentials=true&otherParam=Stuff.
When making a request with Retrofit using an OKHttp Client with interceptors to add headers:
(Authorization: Bearer + access_token)
(User-Agent: "user_agetn_as_described_by_reddit")
Using the oauth.reddit.com/.json URL as recommended by Reddit, I get a 403. Now, when I do this same thing on Postman or something similar, I get a 200 and the expected JSON.
Is anyone aware of something related to Android or Retrofit or OKHttp that could be causing me this pain?
I was using the auth code instead of the access_token to make my requests. A mistake from my side. You should use the auth code to make a token request.
I am using retrofit on newsApi. I am trying to hit endpoint
https://newsapi.org/v2/sources?apiKey=xxxxx
In case of wrong api key server is returning:
{"status":"error","code":"apiKeyInvalid","message":"Your API key is invalid or incorrect. Check your key, or go to https://newsapi.org to create a free API key."}
and in case of no api key server is returning:
{“status”:“error”,“code”:“apiKeyMissing”,“message”:“Your API key is missing. Append this to the URL with the apiKey param, or use the x-api-key HTTP header.”}
but in my application retrofit is returning following for both the cases:
Response{protocol=http/1.1, code=401, message=Unauthorized, url=https://newsapi.org/v2/sources}
just the url is changed for both cases but message and code is same.
Why is retrofit modifying server response and how can I get the original server message or response?
Thanks in advance.
Not having an api key makes you unauthorized, so Retrofit is not wrong to access the error body check out this previous answer
I am using Retrofit for all my api calls in my application. This is the first time I am using it and its very easy to implement.
But my server side has recently updated and they have enabled Oauth 2.
I get an access token in my sign in response which I need to pass in the header.
Please help me to do this, I know how to pass the values in the header, but the thing i need to know is, In what format should I pass the access token
Please Help!
Thanks in advance!
the OAuth 2.0 specification says access tokens can be passed in an Authorization header as in
Authorization: Bearer <access_token>
Is there anyway I can implement Http Digest Authentication using Google Http Java Client on Android, the request doesn't seem to have any exposed methods where I can specify the authentication.
Thanks.
Akshay
There is a feature request filed here: http://code.google.com/p/google-http-java-client/issues/detail?id=163
You can implement this manually by calling HttpRequest.getHeaders().setAuthorization(String), but you'd need to implement the logic to compute the "Authorization" header. If someone can provide the Java logic to compute the "Authorization" header for HTTP Digest, please post it here and we can mark that as the better answer :)