django JWT asking for username/password - django

I can successfully connect via CURL using the example posted in their documentation here:
http://getblimp.github.io/django-rest-framework-jwt/#usage
The problem comes from trying to use Postman. I set the authorization to Basic and put in my username/password and I get a 400 response with the following json:
{
"username": [
"This field is required."
],
"password": [
"This field is required."
]
}
I'm not sure if I'm missing something obvious.

Instead of passing the username and password as part of the header send it as data in the body instead. Here's an example of doing this with jQuery: http://jpadilla.com/post/73791304724/auth-with-json-web-tokens
Taking from the example the data you pass in the body should look like this:
{ username: "admin", password: "abc123"}

Related

Google : contact search [Method: people.searchDirectoryPeople ]

I'm using google directory search API but i coudn't retrive the users names(firstName, lastName) details in response even after applying proper readMask
below is the request details:
{
"method": "GET",
"headers": {
"Authorization": "Bearer access_token",
"Content-Type": "application/json"
},
"uri": "https://people.googleapis.com/v1/people:searchDirectoryPeople?query=ajay&readMask=names,nicknames,addresses,calendarUrls,emailAddresses,organizations,phoneNumbers,photos,relations&sources=DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT&sources=DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE"
}
NOTE: I'm getting the proper results with api, but issue is for some contact results, i'm not getting names(firstname, lastname) data/info in the response
If you are getting a "PERMISSION_DENIED" error, this means the access token you are using doesn't have the directory access scope:
https://www.googleapis.com/auth/directory.readonly
Which is required for accessing directory contacts.
Also your sources param should be:
sources=DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT,DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE
and not
sources=DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT&sources=DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE
P.S.
It's a very bad idea to post real access-tokens in public posts, you should always redact secrets when you post your API requests online.

How to create signup test that works every time without changing user signup data?

I created a Sign Up test in postman and linked it to my website Sign Up endpoint.
However, because Postman uses this test to actually create a user, I can only use it once. (If I want this test to work again, I need to change the email and name of the created user.)
I wonder is there a way to make this test work repeatedly?
Sign up endpoint is
http://localhost:8000/auth/users/
user test data:
{
"email": "newuser#gmail.com",
"name": "newuser",
"password": "testuser12345",
"re_password": "testuser12345"
}
{
"email": "{{$randomEmail}}",
"name": "{{$randomFirstName}}",
"password": "testuser12345",
"re_password": "testuser12345"
}
You can use postman dynamic variable,
https://learning.postman.com/docs/writing-scripts/script-references/variables-list/

Intercom API (v2.0) search conversation not working

I tried to search conversation from Intercom API using Postman but it always return server error message.
I just followed their API docs.
request url: POST https://api.intercom.io/conversations/search?query=updated_at>1590278400
The query should be in JSON format in the Body, not in the querystring like you do in your example:
{
"query": {
"field": "updated_at",
"operator": ">",
"value": 1590278400
}
}
In Postman it looks like this (note: don't forget to add your authentication)

Getting "Bad Request" for Postman API

I simply took an example from Postman API Documentation for Create Collection and removed the extra request outside the folder.
My intention is to create just a folder with 1 request in it.
Here is the request:
{
"collection":{
"variables":[
],
"info":{
"name":"Sample Collection",
"description":"This is just a sample collection.",
"schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item":[
{
"name":"This is a folder",
"description":"",
"item":[
{
"name":"Sample POST Request",
"request":{
"url":"echo.getpostman.com/post",
"method":"POST",
"header":[
{
"key":"Content-Type",
"value":"application/json",
"description":""
}
],
"body":{
"mode":"raw",
"raw": "{
\"data\": \"123\"
}"
},
"description":"This is a sample POST Request"
},
"response":[
]
}
]
}
]
}
}
But for this, I am getting "Bad Request" error, what exactly is wrong with my request?
EDIT - Here's what it looks like in Postman
To me, it looks like you’re trying to send the whole collection json file back to that route.
The JSON in the request body on the image is what you would import into Postman to get the Sample Collection folder. This contains a request called Sample POST Request
Copy the request body JSON and save it as a .json file - Then import this using the Import feature in the top left on the application.
This will then create the folder for you in the application with the sample POST request.
If you send it to the echo URL, you will receive a response telling you that the URL has now changed to https://postman-echo.com/post - Add this new URL into the address bar and hit Send.

Get user email server-side facebook

So I want to get users email address with my server-side code.(I can get it on client side) My apps scope is set to:
"scopes":["public_profile","email"]}
What I'm able to-do at the moment is verify that the users token is valid. But I'd like to request the email as well - just to make sure on server side, that i can log the person in to my website.
I use this address to verify the token belongs to my app:
https://graph.facebook.com/debug_token?input_token=%REPLACE%&access_token=%REPLACE%
How should my request look like if I'd like to next ask for users email on server side?
Appears another option (once/if you know the token belongs to your app) is:
https://graph.facebook.com/me&access_token=USER_ACCESS_TOKEN
by default it only returns id, if you want more, ex email:
https://graph.facebook.com/me?fields=email&access_token=USER_ACCESS_TOKEN
which returns both id and email.
One solution is:
https://graph.facebook.com/v2.1/<user_id>?access_token=<your_app_access_token>
will return:
{
"id": "<id>",
"email": "mihkel\u0040gmail.ee",
"first_name": "Mihkel",
"gender": "male",
"last_name": "Lastname",
"link": "https://www.facebook.com/app_scoped_user_id/<id>/",
"locale": "en_US",
"name": "Mihkel Lastname"
}
if you need only email you can set fields=email parameter :)
You need USER ACCESS TOKEN to get user mail Id,
you can the access token from the response of API call
response.authResponse.accessToken;