Examples for using Google Admin SDK for .NET - passwords

I am trying to find an example in .NET to gerneate the following call to the Google Admin API:
PUT https://www.googleapis.com/admin/directory/v1/users/user%40domain.com?key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ya29.1.AADtN_U3
X-JavaScript-User-Agent: Google APIs Explorer
{
"password": "7c4a8d09ca3762af61e59520943dc26494f8941b",
"hashFunction": "SHA-1"
}
I cannot seem to find any code examples for .net as to how to duplicate this. The page https://developers.google.com/admin-sdk/directory/v1/reference/users/update demonstrates the functionality I am trying to localize and use from a .NET application. Any help would be appreciated. We need to leverage this API for an initial password update. We do not allow our students to change passwords so this JSon update is required for us to be able to use Google Apps for Education.

I fought this for a week or so and finally got it to work.
Blogged about it here - how to setup your project, developer console, admin console and .net
http://blog.mwpreston.net/2014/10/17/google-admin-sdk-apis-and-net-integration-changing-a-users-password/

Related

How do API Data Studio scopes works?

I am using Postman in order to test the Google Data Studio APIs.
I get the following error for the call: https://datastudio.googleapis.com/v1/assets:search?assetTypes=Report
{
"error":{
"code":403,
"message":"Request had insufficient authentication scopes.",
"status":"PERMISSION_DENIED"
}
}
The rights are present:
And no scope of Google Data Studio is present here to carry out other tests:
https://developers.google.com/oauthplayground/
You need https://www.googleapis.com/auth/datastudio scope to use the Data Studio API. You API client should also be authorized (see instructions).
The API is not supported by Google at all. You can't use Oauth dialog.

Attempting to connect to Oro 4.1.1 Web API via the OAuth

I am trying to utilize the OroCommerce Web API which was introduced to interact with my clients.
The first step of oauth2-token seems to be working well, but he consequent requests to the api's such as customers GET, customerusers GET etc all end up with 401-Unauthorized Error.
I am trying to test the whole flow through the POSTMAN.
I have checked the Web API access is enabled and also verified that the guest users are enabled.
What's strange is the the /api/doc seems to be working well, but when I try to mimic the same via POSTMAN, it always ends up with 401 -Unauthorized Access.
Any idea why it could be failing?
Make sure you included Content-Type and Bearer prefixed Authorization headers in the request built using POSTMAN. Like explained in the OroCommerce documentation.
The authentication with Bearer header also explained in POSTMAN documentation.

Password protect OneDrive folder link

Does anyone have experience using the OneDrive api?
I want to be able to create a password protected link to a folder in my OneDrive using the Microsoft Graph api. The api seems to have a CreateLink action that can create a link but it doesn't seem to document that I can include a password when it is created.
Does anyone know if you can create password protected links via the Microsoft Graph api?
I've include the URL to the documentation I am looking at.
https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http
Many thanks in advance.
Rhyd.
It's exposed on the beta endpoint but not yet on v1.0. Check out the following documentation:
https://learn.microsoft.com/en-us/graph/api/resources/permission?view=graph-rest-beta
Hopefully it'll be pushed to v1.0 soon.
Update 2019-07-12
The documentation for createLink appears to be lacking in beta with respect to password support. A request like the following should work though:
POST /me/drive/items/{itemId}/createLink
Content-type: application/json
{
"type": "view",
"scope": "anonymous",
"password": "itsasecret"
}

Exact online REST API: POST call not working

I am trying to make a post call in Exact Online REST API. I'm trying to create a SalesInvoiceLine. I can perfectly do a GET call via my browser. I am logged in in Exact Online so I don't need authentication since this should be passed via a cookie. I tried POST via a browser. The browser prompts me to login, when I do nothing happens. I've also tried this in Postman:
I am 100% certain these initials are correct, I can login with them in Exact Online. What am I doing wrong?
If this is not the way, how can I post data to Exact Online? There are not that many concrete examples to find online.
You can't log on to the Exact Online REST API with Basic authentication, the mode you are using now.
The web service uses OAuth as authentication mechanism, meaning you have to acquire a token first. The steps to do so are outlined in the official documentation.
It will need some work on your end to register an app, get the flow up and running. Depending on your business needs, you might be helped with one of the apps for Exact Online by the company I work for.
You need to retrieve the CurrentDivision through GET Request https://{Base Uri}/api/v1/current/Me only from OAuth then you need to assign
CurrentDivision to whatever may be the API call .../api/v1/{CurrentDivision}/../....
Without authorization by Auth 2.0, neither is impossible.
To authorize the ExactOnline API calls you have to do the following:
Register the app in the developer portal. Bear in mind that you have to do a separate registration for French, UK or Dutch version of ExactOnline (this is indeed a pain).
In case you want your application to be used by other accounts than yours, you have to submit the app for validation, this usually takes 2-3 weeks.
EO uses standard OAuth 2.0 schema (very similar to what Google is using with their services). You have to use endpoint GET /api/oauth2/auth for building an authorization link and endpoint POST /api/oauth2/token for obtaining both access and refresh tokens.
Please bear in mind that many Auth 2.0 services are proving long-lasting refresh token. This is not the case of EO. The refresh token is invalidated every time when the access token is requested (endpoint POST /api/oauth2/token). With access token new refresh token is supplied, so make sure you update you refresh token as well.
The access token is placed in HTTP header as "Authorization: Bearer {{ACCESS_TOKEN}}"
In case you want to automate the EO API calls and do not want to code anything on your own, you can try one of the pre-build Exact Online API connectors, created by the company I work for.

How to use Google sheets REST API directly to create a sheet

I have a PHP application which, unfortunately, already uses the 1.1.4 version of the Google Client API, and I am unable to change that, which makes the 2.X version of the Google PHP Sheets API unavailable to me.
However, I'm hoping to be able to use the Google Sheets REST API directly, making my own curl calls (using Guzzle if that's at all interesting).
I'm brand new to the Google API and I've been all over their documentation, but I haven't been able to figure out how to do some basic things.
For the purposes of this question I want to simply create a new Google spreadsheet via the API, from a tool like POSTman.
I get that I first have to obtain an OAuth2 token via https://www.googleapis.com/auth/spreadsheets. The problem is that I can't quite figure out what to pass this call. I'm assuming it requires a GET since POST returns an error saying that method is unavailable.
Once I get that token, how do I use it when I POST to https://sheets.googleapis.com/v4/spreadsheets
Can someone provide a very basic example of the calls I might make directly to simply create a very basic default spreadsheet?
Or am I thinking about this all wrong? All help is appreciated.
If you already have an OAuth2 access token, you can pass it in the "Authorization" header:
curl -L -d '{}' \
-H "Authorization: Bearer <INSERT ACCESS TOKEN HERE>" \
-H 'Content-Type: application/json' \
https://sheets.googleapis.com/v4/spreadsheets
I just verified that curl command creates a new sheet.
Unfortunately as you already indicated, that's probably the simple part, and Getting an OAuth2 access token is more challenging.
Here's a (relatively painful, unfortunately) approach I use sometimes:
You should first create your own project in the API Console or Cloud Platform console, and configure it for your own OAuth2 client id and client secret.
Next, for just playing around, from the Google OAuth2 Developer Playground at https://developers.google.com/oauthplayground/, set your Client Id and Client Secret under the "OAuth 2.0 configuration" (it's the Settings icon - the little gear in the top right). The places to enter those will be hidden until you check "Use your own OAuth credentials". You can then get an access token, with the scopes https://www.googleapis.com/auth/spreadsheets and https://www.googleapis.com/auth/drive, by following the steps on the left.
For more playing around, you could then construct the POST right in step 3, or use the access token from Step 2 in the curl command above.
Best of luck - it's tricky stuff to get the auth parts right. There are lots of moving parts, and I'm just illustrating the high points here.
Tragedy about the library issue -- the PHP Quick Start appears to deal with the auth relatively cleanly.
Tim
Here's the official spreadsheets.create reference. Here's a list of Sheets API Samples. I would suggest that you leave the current version you're using and play with the PHP Quickstarts just so you can have a grasp of how it works.
This is going to be less than satisfying, but after fighting with it a while I looked to see if I could go against the premise of my question: That I couldn't upgrade to the latest Google Sheets PHP API.
As it turns out there was a way. That made all of this a lot easier.
Google's documentation is frustratingly incomplete, but I managed to get it all working anyway. Both of you gave me key pointers. Thanks for your help.