Django OAuth Toolkit Toen Generation












0















Using Django OAuth Toolkit, I have authorization_grant_type set to password and skip_authorization set to true. I am able to generate tokens and refresh tokens using curl without an issue using the following command:



curl -X POST -d "grant_type=password&username=username&password=password" http://p6ge67ihXcwECuy7Z7iomyv16VlEk4uX6B886UWl:NZK5WUWsdb1oI1aAXAy3EOLx6zbXBrtVEIUoI7pK9ZLpwkMTvIcq3FMycHklGjJazHj4TguPPvpEL1JNmL6uZz594DjNk99nKu6Uq4Z66mM26AWD63D9WO449exUjYq3@localhost:8000/o/token/


But when I try substituting this command with a POST and invoke that POST from a Django view, I get the following:



<Response [401]>
Unauthorized: /o/token/


Any clue why this happening? My POST code is as follows:



data = {
'grant_type': 'password',
'username': 'username',
'password': 'password'
}

response =


requests.post('http://p6ge67ihXcwECuy7Z7iomyv16VlEk4uX6B886UWl:NZK5WUWsdb1oI1aAXAy3EOLx6zbXBrtVEIUoI7pK9ZLpwkMTvIcq3FMycHklGjJazHj4TguPPvpEL1JNmL6uZz594DjNk99nKu6Uq4Z66mM26AWD63D9WO449exUjYq3@localhost:8000/o/token/', data=data)



What am I missing? Any help would be greatly appreciated. Thanks.










share|improve this question























  • what is the value of response.contents?

    – rikAtee
    Nov 13 '18 at 20:57











  • Okay, now I added a header (headers = {'Content-Type': 'application/json'}) to the POST call and response.contents = b'{"error": "unsupported_grant_type"}'. Apparently the client ID and client secret are now being accepted but the grant type isn't. And even if I change the grant type to authorization_code, the error persists. Any thoughts?

    – Foobar
    Nov 13 '18 at 22:25
















0















Using Django OAuth Toolkit, I have authorization_grant_type set to password and skip_authorization set to true. I am able to generate tokens and refresh tokens using curl without an issue using the following command:



curl -X POST -d "grant_type=password&username=username&password=password" http://p6ge67ihXcwECuy7Z7iomyv16VlEk4uX6B886UWl:NZK5WUWsdb1oI1aAXAy3EOLx6zbXBrtVEIUoI7pK9ZLpwkMTvIcq3FMycHklGjJazHj4TguPPvpEL1JNmL6uZz594DjNk99nKu6Uq4Z66mM26AWD63D9WO449exUjYq3@localhost:8000/o/token/


But when I try substituting this command with a POST and invoke that POST from a Django view, I get the following:



<Response [401]>
Unauthorized: /o/token/


Any clue why this happening? My POST code is as follows:



data = {
'grant_type': 'password',
'username': 'username',
'password': 'password'
}

response =


requests.post('http://p6ge67ihXcwECuy7Z7iomyv16VlEk4uX6B886UWl:NZK5WUWsdb1oI1aAXAy3EOLx6zbXBrtVEIUoI7pK9ZLpwkMTvIcq3FMycHklGjJazHj4TguPPvpEL1JNmL6uZz594DjNk99nKu6Uq4Z66mM26AWD63D9WO449exUjYq3@localhost:8000/o/token/', data=data)



What am I missing? Any help would be greatly appreciated. Thanks.










share|improve this question























  • what is the value of response.contents?

    – rikAtee
    Nov 13 '18 at 20:57











  • Okay, now I added a header (headers = {'Content-Type': 'application/json'}) to the POST call and response.contents = b'{"error": "unsupported_grant_type"}'. Apparently the client ID and client secret are now being accepted but the grant type isn't. And even if I change the grant type to authorization_code, the error persists. Any thoughts?

    – Foobar
    Nov 13 '18 at 22:25














0












0








0








Using Django OAuth Toolkit, I have authorization_grant_type set to password and skip_authorization set to true. I am able to generate tokens and refresh tokens using curl without an issue using the following command:



curl -X POST -d "grant_type=password&username=username&password=password" http://p6ge67ihXcwECuy7Z7iomyv16VlEk4uX6B886UWl:NZK5WUWsdb1oI1aAXAy3EOLx6zbXBrtVEIUoI7pK9ZLpwkMTvIcq3FMycHklGjJazHj4TguPPvpEL1JNmL6uZz594DjNk99nKu6Uq4Z66mM26AWD63D9WO449exUjYq3@localhost:8000/o/token/


But when I try substituting this command with a POST and invoke that POST from a Django view, I get the following:



<Response [401]>
Unauthorized: /o/token/


Any clue why this happening? My POST code is as follows:



data = {
'grant_type': 'password',
'username': 'username',
'password': 'password'
}

response =


requests.post('http://p6ge67ihXcwECuy7Z7iomyv16VlEk4uX6B886UWl:NZK5WUWsdb1oI1aAXAy3EOLx6zbXBrtVEIUoI7pK9ZLpwkMTvIcq3FMycHklGjJazHj4TguPPvpEL1JNmL6uZz594DjNk99nKu6Uq4Z66mM26AWD63D9WO449exUjYq3@localhost:8000/o/token/', data=data)



What am I missing? Any help would be greatly appreciated. Thanks.










share|improve this question














Using Django OAuth Toolkit, I have authorization_grant_type set to password and skip_authorization set to true. I am able to generate tokens and refresh tokens using curl without an issue using the following command:



curl -X POST -d "grant_type=password&username=username&password=password" http://p6ge67ihXcwECuy7Z7iomyv16VlEk4uX6B886UWl:NZK5WUWsdb1oI1aAXAy3EOLx6zbXBrtVEIUoI7pK9ZLpwkMTvIcq3FMycHklGjJazHj4TguPPvpEL1JNmL6uZz594DjNk99nKu6Uq4Z66mM26AWD63D9WO449exUjYq3@localhost:8000/o/token/


But when I try substituting this command with a POST and invoke that POST from a Django view, I get the following:



<Response [401]>
Unauthorized: /o/token/


Any clue why this happening? My POST code is as follows:



data = {
'grant_type': 'password',
'username': 'username',
'password': 'password'
}

response =


requests.post('http://p6ge67ihXcwECuy7Z7iomyv16VlEk4uX6B886UWl:NZK5WUWsdb1oI1aAXAy3EOLx6zbXBrtVEIUoI7pK9ZLpwkMTvIcq3FMycHklGjJazHj4TguPPvpEL1JNmL6uZz594DjNk99nKu6Uq4Z66mM26AWD63D9WO449exUjYq3@localhost:8000/o/token/', data=data)



What am I missing? Any help would be greatly appreciated. Thanks.







django oauth token toolkit






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 19:35









FoobarFoobar

140119




140119













  • what is the value of response.contents?

    – rikAtee
    Nov 13 '18 at 20:57











  • Okay, now I added a header (headers = {'Content-Type': 'application/json'}) to the POST call and response.contents = b'{"error": "unsupported_grant_type"}'. Apparently the client ID and client secret are now being accepted but the grant type isn't. And even if I change the grant type to authorization_code, the error persists. Any thoughts?

    – Foobar
    Nov 13 '18 at 22:25



















  • what is the value of response.contents?

    – rikAtee
    Nov 13 '18 at 20:57











  • Okay, now I added a header (headers = {'Content-Type': 'application/json'}) to the POST call and response.contents = b'{"error": "unsupported_grant_type"}'. Apparently the client ID and client secret are now being accepted but the grant type isn't. And even if I change the grant type to authorization_code, the error persists. Any thoughts?

    – Foobar
    Nov 13 '18 at 22:25

















what is the value of response.contents?

– rikAtee
Nov 13 '18 at 20:57





what is the value of response.contents?

– rikAtee
Nov 13 '18 at 20:57













Okay, now I added a header (headers = {'Content-Type': 'application/json'}) to the POST call and response.contents = b'{"error": "unsupported_grant_type"}'. Apparently the client ID and client secret are now being accepted but the grant type isn't. And even if I change the grant type to authorization_code, the error persists. Any thoughts?

– Foobar
Nov 13 '18 at 22:25





Okay, now I added a header (headers = {'Content-Type': 'application/json'}) to the POST call and response.contents = b'{"error": "unsupported_grant_type"}'. Apparently the client ID and client secret are now being accepted but the grant type isn't. And even if I change the grant type to authorization_code, the error persists. Any thoughts?

– Foobar
Nov 13 '18 at 22:25












1 Answer
1






active

oldest

votes


















0














Check in Django admin (/admin/oauth2_provider/application, in my case) if the grant type is accepted for that Application:



enter image description here



try Resource owner password-based or Client credentials






share|improve this answer
























  • It's set to "Resource owner password-based". When I make the call using cURL from the command line it generates and retrieves the token but not when I try to call the same service using a POST call. Any more thoughts?

    – Foobar
    Nov 14 '18 at 0:30











  • Any other suggestions? Thanks.

    – Foobar
    Nov 14 '18 at 18:02











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53288309%2fdjango-oauth-toolkit-toen-generation%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Check in Django admin (/admin/oauth2_provider/application, in my case) if the grant type is accepted for that Application:



enter image description here



try Resource owner password-based or Client credentials






share|improve this answer
























  • It's set to "Resource owner password-based". When I make the call using cURL from the command line it generates and retrieves the token but not when I try to call the same service using a POST call. Any more thoughts?

    – Foobar
    Nov 14 '18 at 0:30











  • Any other suggestions? Thanks.

    – Foobar
    Nov 14 '18 at 18:02
















0














Check in Django admin (/admin/oauth2_provider/application, in my case) if the grant type is accepted for that Application:



enter image description here



try Resource owner password-based or Client credentials






share|improve this answer
























  • It's set to "Resource owner password-based". When I make the call using cURL from the command line it generates and retrieves the token but not when I try to call the same service using a POST call. Any more thoughts?

    – Foobar
    Nov 14 '18 at 0:30











  • Any other suggestions? Thanks.

    – Foobar
    Nov 14 '18 at 18:02














0












0








0







Check in Django admin (/admin/oauth2_provider/application, in my case) if the grant type is accepted for that Application:



enter image description here



try Resource owner password-based or Client credentials






share|improve this answer













Check in Django admin (/admin/oauth2_provider/application, in my case) if the grant type is accepted for that Application:



enter image description here



try Resource owner password-based or Client credentials







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 0:07









rikAteerikAtee

4,83552958




4,83552958













  • It's set to "Resource owner password-based". When I make the call using cURL from the command line it generates and retrieves the token but not when I try to call the same service using a POST call. Any more thoughts?

    – Foobar
    Nov 14 '18 at 0:30











  • Any other suggestions? Thanks.

    – Foobar
    Nov 14 '18 at 18:02



















  • It's set to "Resource owner password-based". When I make the call using cURL from the command line it generates and retrieves the token but not when I try to call the same service using a POST call. Any more thoughts?

    – Foobar
    Nov 14 '18 at 0:30











  • Any other suggestions? Thanks.

    – Foobar
    Nov 14 '18 at 18:02

















It's set to "Resource owner password-based". When I make the call using cURL from the command line it generates and retrieves the token but not when I try to call the same service using a POST call. Any more thoughts?

– Foobar
Nov 14 '18 at 0:30





It's set to "Resource owner password-based". When I make the call using cURL from the command line it generates and retrieves the token but not when I try to call the same service using a POST call. Any more thoughts?

– Foobar
Nov 14 '18 at 0:30













Any other suggestions? Thanks.

– Foobar
Nov 14 '18 at 18:02





Any other suggestions? Thanks.

– Foobar
Nov 14 '18 at 18:02


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53288309%2fdjango-oauth-toolkit-toen-generation%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma