My REST API with basic authentication works fine using Rest client (Google Chrome extn).
The same also working fine with below Curl command:
curl --header "Accept:application/json" -i --user user1:user1Pass http://localhost:8080/authenticate
But when testing the same in browser I'm getting 404 not found error. The browser URL: http://user1.user1Pass#localhost:8080/authenticate
Can anyone please help me on this?
You're using a period instead of a colon.
The format of the url should be http://user1: user1Pass#localhost:8080/authenticate
The main point is you need to separate username and password by colon.
Related
I'm trying to use this package https://github.com/RealmTeam/django-rest-framework-social-oauth2
In Google Example
When I try to request an access_token by
curl -X POST -d "grant_type=convert_token&client_id=<django-oauth-generated-client_id>&client_secret=<django-oauth-generated-client_secret>&backend=google-oauth2&token=<google_token>" http://localhost:8000/auth/convert-token
it's saying
{"error":"access_denied","error_description":"Your credentials aren't allowed"}
What should I put in
django-oauth-generated-client_id and django-oauth-generated-client_secret
is that the thing where you create new application or should I put the google's client and secret ids
I try both but still not working.
Also in
token=<google_token>
I try to put the Authorization code or the access_token in this image but still not working
enter image description here
Can someone help thank you
I am trying to get the REST API of keycloak to work.
Thanks to this post I was able to get the token. But when trying the example for the list of users in the first answer, I get the error:
"error": "RESTEASY003210: Could not find resource for full path: http://PATHTOCEAKLOAK:81/auth/user/realms/master/users"
Here my request with Postman:
As I am using a Bitnami-container the admin is called user that's why I am using /auth/user/ instead of /auth/admin/
For those who are still facing this error and using 17.0+ version of Keycloak, there's a change in endpoints as per the official documentation. I resolved this issue by just using {realm}/user and omitting /auth in between.
In addition to #Akanksha_p's answer, here is a command to get the token using curl:
curl -k -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=your-client" -d "username=some-user" -d "password=hardpassword" -d "grant_type=password" -X POST https://your.fqdn.server:8443/realms/yourrealm/protocol/openid-connect/token
I was actually working on the same and using docker image of bitnami/keycloak:latest
it worked with just removing /auth from base path and keeping it as /admin
something like this (GET http://localhost:8085/admin/realms/test-realm/users)
enter image description here
If you want to know wich url are available on your current realm you can go in Realm -> Settings and click on "Ednpoints" link.
Or directly go to the following url : http://{host}:{port}/realms/{your_realm}/.well-known/openid-configuration.
#Kostanos - I will try to get the /auth/ Path back with a reverseproxy in front of the keycloak. Like nginx and make a rewrite
I have a script that I'd like to be able to access via a curl command against its https://raw.githubusercontent.com/... location. Using git.io, it's really easy to shorten this URL to something like https://git.io/ABCDE.
But there's an issue related to the fact that my script exists in a private repository. If I directly curl against the githubusercontent URL, I get 404: Not Found. I'm able to bypass this by passing an authorization header with the request, e.g.
$ curl -H "Authorization: token <My Github Personal Access Token>" \
https://raw.githubusercontent.com/...
> !#/bin/bash
... # rest of script
However, when I use my shortened URL, I don't get anything back. Not even a 404.
$ curl -H "Authorization: token <My Github Personal Access Token>" \
https://git.io/ABCDE
$
Anyone know what's going on here?
The way a URL shortener works is that it issues some sort of 3xx-series HTTP status code that redirects you to the new location, and then you make your request against that new location. However, by default, curl does not follow redirects, so all you see when you make your request is the output from git.io, which in this case is nothing.
If you want to follow redirects, then you should use the -L option to curl, which will make it follow redirects. Note that this can be insecure in many cases when passing credentials, since any credentials passed with -H will be passed to any remote server that the data is redirected to. In this case, that's what you want, but it can be a security problem in other cases if the credentials were only intended for the original server.
Im new to php n curl.. Im going to use Facebook's OGP for my facebook app that im using in my website..I created OPG setings for publish my app activities to the users profile.
https://developers.facebook.com/docs/beta/opengraph/tutorial/
After i have setup accouring to the Tutorial(above url) they give me curl code like
curl -F 'access_token=AAACAwq1JHZA0BAA94uB50n7O71B6PmMUsFAydKBKCv1HcdJw9NwK8MZC83vL2YqUXojQ0aXH8EBjTweKHQTr4bZBKlgkOJ0nB5dBDu6A09UbI0lmXZBs' \
-F 'friend=http://samples.ogp.me/205849716166552' \
'https://graph.facebook.com/me/yalumalu:add'
and
curl 'https://graph.facebook.com/me/yalumalu:add?access_token=AAACAwq1JHZA0BAA94uB50n7O71B6PmMUsFAydKBKCv1HcdJw9NwK8MZC83vL2YqUXojQ0aXH8EBjTweKHQTr4bZBKlgkOJ0nB5dBDu6A09UbI0lmXZBs'
I don't know how to run these codes in my site..Tutorial says something else there no curl codes in tutorial that given by facebook.. I tried alot.. Someone please help me to do this..
cURL is a simple way to HTTP GET/POST/DELETE requests.
If you need to achieve similar behaviour in your site you need to choose a language that supports sending these requests.
For example you can use PHP and cURL options as well as the PHP SDK or you can use JavaScript to do the same with the JS SDK
I’m trying to use the Github v3 API - I already implemented the required OAuth flow and it works well.
Now I’m trying some of the Repos API endpoints (http://developer.github.com/v3/repos/).
So far, I’m able to get a List of my repos using: GET /user/repos
However, when I try to create a repo using POST /user/repos, I get a 404.
Any thoughts what I might be doing wrong?
Joubert
Can you please tell us how exactly you did the HTTP request? The 404 sounds like you were using a wrong path, probably. But to give a reliable answer instead a wild guess, we need to see your request, including how you are sending your token, just mask it with 'xxx' or something.
I'll show you in the meantime an example request, that is working:
curl -XPOST -H 'Authorization: token S3CR3T' https://api.github.com/user/repos -d '{"name":"my-new-repo","description":"my new repo description"}'
You would need to replace the OAuth token of course: S3CR3T
I had the same issue. The reason why you are getting a 404 with your oauth access token is that when you authorize to github you need to also additionally pass the scopes you want. For example, in the header you should see "X-OAuth-Scopes: repo, user", which means this user has read/write access to his profile and repositories. Once you have set the correct scopes you should be able to do POST/PUT requests just fine.
To see whether or not you have the correct permissions. You can do something like the following. Substitute the XXXXXXX with your access token.
curl -I https://api.github.com/user?access_token=XXXXXXXX
For creating repositories as a user you can use an personal access token and basic auth, which can be much simpler when you are fluffing around on the command line and have 2FA enabled.
curl -d '{"name":"test"}' -u githubuser:personaccesstoken https://api.github.com/user/repos
Create a personal access token here https://github.com/settings/tokens and make sure it has the 'repo' scope.
This script lets you read in in the token and project name as variables so you can use it in a script
#!/usr/bin/env bash -u
#
TOKEN=`cat token_file`
PROJECT=myproject
curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d '{"name": "'"$PROJECT"'"}' https://api.github.com/user/repos?access_token=$TOKEN