I want to update group settings via web API request. All necessary authorization scopes are provided and groups settings are enabled. I send a put request:
body = {
"whoCanPostMessage": "ALL_MEMBERS_CAN_POST",
"whoCanViewMembership": "ALL_MEMBERS_CAN_VIEW"
}
response = requests.put(
"https://www.googleapis.com/groups/v1/groups/%s" % group_id,
data=json.dumps(body),
headers={
'Content-type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer %s' % access_token
}
)
but the server responds:
<Response [500]> Internal Server Error
headers:
Cache-Control: private, max-age=0
Content-Encoding: gzip
Content-Length: 122
Content-Type: application/json; charset=UTF-8
Date: Fri, 05 Feb 2016 18:36:53 GMT
Expires: Fri, 05 Feb 2016 18:36:53 GMT
Server: GSE
Vary: Origin, X-Origin
content:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "Backend Error"
}
],
"code": 500,
"message": "Backend Error"
}
}
The same error occurs when I use Try It! in the Groups Settings API Reference.
Do you have Google Groups for business enabled in your domain?
I found that UniqueGroupID field should be set to a group email address not a group id. It works now.
Related
I'm trying to authenticate against couchdb using this documentation
When I do
# first request
const url = 'http://localhost:5984/_session'
fetch(url, {
method: 'POST',
headers: {
"Content-Type": "application/json",
},
body : JSON.stringify({
"name": "my_username",
"password": "my_password"
}),
}).then( data => {
console.log(data)
}).catch(e => {
console.log('Error', e)
})
If one of my_username or my_password IS NOT right i get:
body: (...)
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 401
statusText: "Unauthorized"
type: "cors"
url: "http://localhost:5984/_session"
which is fine.
But, if one of my_username or my_password IS right i get:
body: ReadableStream
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "cors"
url: "http://localhost:5984/_session"
instead of
HTTP/1.1 200 OK
Cache-Control: must-revalidate
Content-Length: 43
Content-Type: application/json
Date: Mon, 03 Dec 2012 01:23:14 GMT
Server: CouchDB (Erlang/OTP)
Set-Cookie: AuthSession=cm9vdDo1MEJCRkYwMjq0LO0ylOIwShrgt8y-UkhI-c6BGw; Version=1; Path=/;
HttpOnly
{"ok":true,"name":"root","roles":["_admin"]} // <-- i expect that
And no cookie set.
I also tried curl, it works :
> curl http://localhost:5984/_session
{"ok":true,"userCtx":{"name":null,"roles":[]},"info":{"authentication_handlers":
["cookie","default"]}}
> curl -X POST http://localhost:5984/_session -H "Content-Type: application/json" -d '{"name":"my_username","password":"my_password"}'
{"ok":true,"name":"my_username","roles":["_admin"]}
But I need it to work in a react app, from http:localhost:3000
Maybe it's CORS related? I enabled CORS in CouchDB settings.
How can i modify the first request in order to get the user object for the name/password supplied?
I think Authentication Set-Cookie produce by backend server not by front end. So you need backend like Node.js to get cookie and then get it again from your front end.
Following this tutorial -> https://developer.vimeo.com/api/upload/thumbnails
I have setup a time of 180s and the request of step 2 has returned status 201.
all the links have a similar format:
https://i.vimeocdn.com/video/<id>_<size>.jpg?r=pad'
Here is the request:
{ protocol: 'https:',
host: 'i.vimeocdn.com',
port: 443,
method: 'PUT',
headers:
{ 'Content-Type': 'image/jpg',
Accept: 'application/vnd.vimeo.*+json;version=3.4',
'User-Agent': 'Vimeo.js/2.1.1',
Authorization: 'Bearer 9a3918a750089766b46f0e8a59a79f49',
'Content-Length': 189 },
body:
'_readableState=&readable=true&_events=&_eventsCount=1&_maxListeners=&path=%2Ffile.jpg&fd=&flags=r&mode=438&start=&end=&autoClose=true&pos=&bytesRead=0&closed=false',
path: '/video/<id>_1920x1080.jpg' }
}
I've tried with that URI but allways get this result:
<html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>
{ connection: 'close',
'cache-control': 'no-cache',
'content-type': 'text/html',
'accept-ranges': 'bytes, bytes',
via: '1.1 varnish, 1.1 varnish',
'access-control-allow-origin': '*',
date: 'Wed, 10 Jun 2020 16:59:05 GMT',
'x-served-by': 'cache-dfw18638-DFW, cache-ewr18125-EWR',
'x-cache': 'MISS, MISS',
'x-cache-hits': '0, 0',
'x-timer': 'S1591808345.129097,VS0,VE49',
'transfer-encoding': 'chunked' }
The token has the following access:
private create edit upload video_files public
I've tried to do the PUT request to the api hostname, but the page couldn't be found.
Any ideas?
Thanks in advance.
I've used the wrong link, the PUT request must be to a link that looks like this:
https://i.cloud.vimeo.com/video/<id>?expires=<timestamp>&sig=<hash>
I am writing to Firebase Database from a Vapor server using the Firebase REST API. Why don't I get a Status code in the header received? This would enable me to check if the write was successful or not.
headerReceived items line 83 in
extensionPutRequestToUsersClaimBookingCleaner are
([Connection: "keep-alive", Cache-Control: "no-cache", Server:
"nginx", Date: "Sun, 27 Aug 2017 21:47:25 GMT", Content-Type:
"application/json; charset=utf-8", Content-Length: "1027",
Strict-Transport-Security: "max-age=31556926; includeSubDomains;
preload", Access-Control-Allow-Origin: "*"])
The response's status code is returned in the status property rather than the headers property.
guard response.status == .created else {
// not a 201 response
}
I'm trying to use Google's Admin SDK to create an orgunit using a shell script. My script is as follows:
# Obtain a token we can use to modify the organisation
auth_header=`oauth2l header --json "..." "admin.directory.orgunit"`
customer_id=...
curl -v -H "Content-Type: application/json" -X POST \
--data-binary "#google-orgunits/technical.json" \
--header "$auth_header" \
"https://www.googleapis.com/admin/directory/v1/customer/$customer_id/orgunits"
This produces the output:
* Trying 216.58.196.138...
* Connected to www.googleapis.com (216.58.196.138) port 443 (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* found 704 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
* server certificate verification OK
* server certificate status verification SKIPPED
* common name: *.googleapis.com (matched)
* server certificate expiration date OK
* server certificate activation date OK
* certificate public key: RSA
* certificate version: #3
* subject: C=US,ST=California,L=Mountain View,O=Google Inc,CN=*.googleapis.com
* start date: Wed, 05 Apr 2017 17:01:30 GMT
* expire date: Wed, 28 Jun 2017 16:56:00 GMT
* issuer: C=US,O=Google Inc,CN=Google Internet Authority G2
* compression: NULL
* ALPN, server accepted to use http/1.1
> POST /admin/directory/v1/customer/.../orgunits HTTP/1.1
> Host: www.googleapis.com
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Type: application/json
> Authorization: Bearer ...
> Content-Length: 157
>
* upload completely sent off: 157 out of 157 bytes
< HTTP/1.1 401 Unauthorized
< Vary: X-Origin
< WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token
< Content-Type: application/json; charset=UTF-8
< Date: Sat, 15 Apr 2017 06:26:27 GMT
< Expires: Sat, 15 Apr 2017 06:26:27 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alt-Svc: quic=":443"; ma=2592000; v="37,36,35"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
There must be some problem here: I appear to be obtaining a valid token, (looks like ya29.ElouBGKFig-nXZ9uykyGoDr0hxAxG5PMJTUh3VmtAtj2SAdYEbH2Coumjp5XoaF232oVx3--2EpTyNi5NgFBNrLINJij9tGL3-64MshEXjHhvkH-1NESoxPeVAU). I've followed all of the instructions here, enabled API access, authorized my API client, everything; but still, not working. Where have I gone wrong?
Try checking the documentation about Directory API: Authorize Requests
Every request your application sends to the Directory API must include an authorization token. The token also identifies your application to Google.
Here's the OAuth 2.0 scope information for the Directory API:
https://www.googleapis.com/auth/admin.directory.orgunit - Global scope for access to all organization unit operations.
https://www.googleapis.com/auth/admin.directory.orgunit.readonly -
Scope for only retrieving organization units.
You can check the OAuth 2.0 Playground, an interactive demonstration of using OAuth 2.0 with Google (including the option to use your own client credentials). Also there are many quickstart that can help you on how to properly authorize a request for Admin SDK.
Hope this helps.
I'm trying to use the Admin SDK Directory API, specifically to retrieve user info as detailed by the Users: get endpoint.
I have requested the following permissions when oauthing
https://www.googleapis.com/auth/admin.directory.user
https://www.googleapis.com/auth/admin.directory.user.readonly
However, when I make the request to get info on a particular user, I get the following response:
HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=UTF-8
Date: Fri, 26 Jul 2013 18:25:29 GMT
Expires: Fri, 26 Jul 2013 18:25:29 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked
{
"error": {
"errors": [
{
"domain": "global",
"reason": "domainCannotUseApis",
"message": "Domain cannot use apis."
}
],
"code": 403,
"message": "Domain cannot use apis."
}
}
I have enabled the Admin SDK in the API Console.
I have tried this on a Google Apps Standard (Free) Edition and also a Google Apps for Nonprofits Edition and get the same error. Does the Admin SDK Directory API require a Google Apps for Business Account?
You need to enable the administrative APIs in the G Suite Control Panel.
I am confused. Does it mean that if our App is listed in the Google Apps Marketplace, domains who install our App still have to manually enable the administrative API?