Alfresco cloud modify file https method - alfresco

I use alfresco cloud.
I can authentificate, get my access_token, and access to a file by having a get request:
[GET] https://api.alfresco.com/mycompany.com/public/cmis/versions/1.0/atom/content?id=id_of_my_file&access_token=my_access_token
Now I want to update the content of the file. The doc say to use PUT request. Is what I did :
[PUT] https://api.alfresco.com/mycompany.com/public/cmis/versions/1.0/atom/content?id=id_of_my_file&access_token=my_access_token
But I have this error :
{
"error":"invalid_request",
"error_description":"Missing access token"
}

As Gagravarr says, try putting your access token in the authorization field of the HTTP request header, like this:
Bearer [your access token]
See "Using the Access Token" in the API documentation PDF.

Related

LinkedIn Access Token Being Used

I've successfully secured my access token for the LinkedIn API. However, when I try to use it to gather user information (currently just my own so I know that the profile has all public settings) using this code:
requestURL = 'https://api.linkedin.com/v2/people/(id:{my_linkedin_id})'
headers = {'Authorization': 'Bearer' + ' ' + access_token}
a = requests.get(requestURL,headers=headers)
could someone elaborate on any steps I might be messing?
When I run this code I keep getting a
<Response [404]>
You have 404 as response and in LinkedIn documentation you can see that:
404 Resource Not Found
This error occurs when your application tries to call an API or fetch
an entity that does not exist. For example, the API to get a friend’s
profile is /v2/people/id={personId}, not /v2/person/id={personId}. In
some cases (Ads, for example), a 404 error is returned when attempting
to access a restricted API. See 403 Access Denied and contact your
partner technical support channel if you continue to see the error.
I think you need too check if your link to resource is good.

Laravel Passport - Grant Type Not Supported

I have installed Laravel Passport per the documentation and I have modified all areas of my code that is required.
I am working on setting up Password Grant Tokens so that users will be able to get an API token when logging in with their username and password for the site. I am hitting an issue though when it comes to the grant_type.
For some reason Laravel is complaining about an invalid grant type.
{
"error": "unsupported_grant_type",
"message": "The authorization grant type is not supported by the authorization server.",
"hint": "Check the `grant_type` parameter"
}
These are the fields that I am posting to /oauth/token
client_id = 4
client_secret = SMiYE7XqDNtXKQnmkYmFnXxfAaV83vRhnJ9zwCtZ
username = jcrawford#domain.com
password = **************
grant_type = password
scope = *
I have run php artisan passport:install and I have also tried running php artisan passport:client --password
Both commands worked and both created the client and secrets, however, I cannot seem to get past the error about the grant_type.
Any suggestions on what I should look at to get this solved so that Password Grant Tokens will work for me?
It appears that you must send the parameters as form data and not in the headers like I was doing... Rookie Mistake!
I'm using Postman and I have put all parameters in Params. Postman shows the following response
{
"error": "unsupported_grant_type",
"message": "The authorization grant type is not supported by the authorization server.",
"hint": "Check the `grant_type` parameter"
}
Now I put all parameters in Body and then press the Send button, It's working well.
For me the problem was that i wasnt using Request $request, i was using RegisterRequest $request which i had created.
Initial URL
https://restfulapi.test/oauth/authorize?client_id=3&redirect_url=http://restfulapi.test?response_type=code
Solution
https://restfulapi.test/oauth/authorize?client_id=3&redirect_url=http://restfulapi.test&response_type=code
I had to replace the question mark before response_type with the &
Reading the Laravel documentation saved me a lot of stress. The oauth\token is used to retrieve token using the grant type specified, the route will return a JSON response containing access_token, refresh_token, and expires_in attributes. The expires_in attribute contains the number of seconds until the access token expires (ref) You are meant to
Install passport
Publish the service providers and migrations and migrate.
Setup a route for login/register to create an account and login.
In your User model, add HasApiTokens from use Laravel\Passport\HasApiTokens;
In your response in your login method, add the token as part of the response.
Test your response on postman

Can't access FireBase Database via HTTP/REST error 403 Forbidden

Swift + Vapor framework for server + Xcode 8.1
I am trying to read Firebase Realtime Database making HTTP requests to my DB, but I get permission denied.
These are the steps:
1. create JWT sign it with secret key downloaded from "console.developers.google.com"
2. send POST request to OAuth2 server and get access token
3. send GET request to firebase database with access token received from OAuth2 server.
I get "Permission denied", HTTP/1.1 403 Forbidden
// the header of the JSON Web Token (first part of the JWT)
let headerJWT = ["alg":"RS256","typ":"JWT"]
// the claim set of the JSON Web Token
let jwtClaimSet =
["iss":"firebase-adminsdk-kxx5h#fir-30c9e.iam.gserviceaccount.com",
"scope":"https://www.googleapis.com/auth/firebase.database", //is this the correct API to access firebase database?
"aud":"https://www.googleapis.com/oauth2/v4/token",
"exp": expDate,
"iat": iatDate]
drop.get("access") { request in
var accesstoken = "ya29.ElqhA-....XXXX"
let responseFirebase = try drop.client.get("https://fir- 30c9e.firebaseio.com/data/Users.json",
headers: ["Authorization":"Bearer \(accesstoken)"],
query: [:])
print("FirebaseResponse_is \(responseFirebase)")
return "success"
}
TLDR; Try placing auth=<TOKEN> in your query string instead of using the authorization header.
The Firebase documentation is unclear on how this works. According to the documentation, there are three methods that should work.
auth=<TOKEN> in query string (link)
access_token=<TOKEN> in query string (link)
Authorization: Bearer <TOKEN> in request header (link)
I'm not convinced that all three methods do actually work however. I'm using method 1 in my application, so I know that one works for sure.
The scope key was missing value https://www.googleapis.com/auth/userinfo.email
let jwtClaimSet =
["iss":"firebase-adminsdk-kxx5h#fir-30c9e.iam.gserviceaccount.com",
"scope": "https://www.googleapis.com/auth/firebase.database
https://www.googleapis.com/auth/userinfo.email",
"aud":"https://www.googleapis.com/oauth2/v4/token",
"exp": expDate,
"iat": iatDate]
I found the answer browsing google groups here
headers: ["Authorization":"Authorization: Bearer \(accesstoken)"],
should be
headers: ["Authorization":"Bearer \(accesstoken)"],

RStudio & RGoogleAnalytics giving Error: redirect_uri_mismatch

I am trying to connect to google analytics from R through Analytics API. Following is my code.
library(RGoogleAnalytics)
oauth_token <- Auth(client.id = "clientID", client.secret = "clientSecret")
When I run above command it gives me following error in browser
Error: redirect_uri_mismatch
The redirect URI in the request, http://localhost:1410/, does not match the ones authorized for the OAuth client.
I have following settings in google developer console
Authorised JavaScript origins : http://localhost:1410
Authorised redirect URIs: http://localhost:8080/oauth2callback
Please help.
You will need to update your redirect URIs to the same port.
http://localhost:1410/oauth2callback
If that does not work, create a new client secret json file. Use "other" as the application type;

Box API: Create folder on behalf of another user

I am able to create folder via put API call.
Now I am trying to use User impersonation to create a new folder giving following headers.
headers = { "Authorization" : "<token>", "As-User" : "237490238" }
It is always giving me 403 forbidden as response.
I also tried creating folder this way via POSTMAN giving X-On-Behalf-Of and X-As-User headers. The response is 201 ( created ) but created_by is not the user (with id = '237490238') provided in headers.
Is it possible to have user impersonation in creating files/folders , creating shared links for files/folders via API?
1: Your Authorization header is not formatted properly. The value needs to be prefixed by Bearer:
headers = {
"Authorization" : "Bearer <token>",
"As-User" : "237490238"
}
2: Ensure that the scope of your authorization token includes Manage an enterprise. This is required in order to use the As-User functionality.

Resources