Google Drive Invalid scope for OAuth 2.0 for TV and Limited-Input Device Applications GODOT

Viewed 118

I'm using the OAuth 2.0 for TV and Limited-Input Device Applications in my Godot project. The scopes allowed are (https://developers.google.com/identity/protocols/oauth2/limited-input-device?authuser=1#allowedscopes).

OpenID Connect, Google Sign-In

email
openid
profile

Drive API

https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.file

YouTube API

https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/youtube.readonly

Below is my Godot (gdscript) function to send the request (clientID is a var with my generated OAuth 2.0 Client ID):

func _make_post_request():
    var oAuthEntry = "https://oauth2.googleapis.com/device/code";
    var params = "scope=email%20profile%20https://www.googleapis.com/auth/youtube&";
    params += "client_id=" + clientID;
    # Add 'Content-Type' header:
    var headers = ["Content-Type: application/x-www-form-urlencoded"]
    $HTTPRequest.request(oAuthEntry, headers, true, HTTPClient.METHOD_POST, params)

This works correctly, for the OpenID and YouTube Scopes.

But when I try to use the Drive API Scopes I get an invalid scope return.

For example:

func _make_post_request():
    var oAuthEntry = "https://oauth2.googleapis.com/device/code";
    var params = "scope=https://www.googleapis.com/auth/drive.appdata&";
    params += "client_id=" + clientID;
    # Add 'Content-Type' header:
    var headers = ["Content-Type: application/x-www-form-urlencoded"]
    $HTTPRequest.request(oAuthEntry, headers, true, HTTPClient.METHOD_POST, params)

I get a return of:

{error:invalid_scope}

Does anybody know why the scope is invalid although it is listed on the allowed page (https://developers.google.com/identity/protocols/oauth2/limited-input-device?authuser=1#allowedscopes)

1 Answers

Posting this in case anyone else ends up here. It seems that drive.appdata is the one not working. Try using just drive.files instead. (Just tried as of 2022-07-12)

Not sure why, and it's frustrating that this issue hasn't been addressed, but try going without drive.appdata

Related