Error: Unauthorized client or scope in request 7


I have had a few emails recently about a strange error from the Google .net Client library. Last night was the first time I saw it on one of my projects personally. I am not sure what is causing the problem exactly. But I can tell you how to fix it.

Error:”unauthorized_client”, Description:”Unauthorized client or scope in request.”, Uri:””

It seams to happen when there is a problem with one or more of the .dlls imported with the NuGet packages. All you have to do is re-install the NuGet package. You don’t even need to uninstall it first. Just run the NuGet command again. It should fix your problem.

If this doesn’t fix your issue please comment below so that we can find more ways of dealing with it.


About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as an application developer and a database expert. I have also been working with Google APIs since 2012 and I have been contributing to the Google .Net client library since 2013. In 2013 I became a a Google Developer Experts for Google Analytics.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

7 thoughts on “Error: Unauthorized client or scope in request

  • Patrik Chynoransky

    Hello,
    I get the same message (but as an exception, not an error) when I try to call the “refreshTokenWithAssertion()” method while authenticating to use Directory API.
    I don’t recall installing the NuGet package. Does this issue apply to Ubuntu OS, too?
    Thanks.

  • Sergio Barbosa

    Hello, very nice blog … congratulations!

    Have any examples of how to use the Google Drive Web Application?

    See the problem below:

    Used the framework 4.0 (VS2013) and Google.Api 1.9 (NuGet). Already released full access and the error persists. I’m trying to set up to authenticate to web application.

    Stack Trace:

    [Win32Exception (0x80004005): An error occurred in sending the command to the application]
    Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +82
    Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) +71
    Google.Apis.Auth.OAuth2.d__1.MoveNext() +262

    [AggregateException: One or more errors occurred.]
    System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) +3548265
    System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) +73
    System.Threading.Tasks.Task`1.get_Result() +10486829
    DriveSample.Page_Load(Object sender, EventArgs e) +194
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
    System.Web.UI.Control.OnLoad(EventArgs e) +92
    System.Web.UI.Control.LoadRecursive() +54
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

  • Juan Pablo

    I re-install but not solutionate
    what can i do ?

    var certificate = new X509Certificate2(“devcoemmi.p12”, “notasecret”, X509KeyStorageFlags.Exportable);
    var serviceAccountEmail = “815410429507-eq884s5pgii5mom1c2t700h715r0c8sd@developer.gserviceaccount.com”;
    var userAccountEmail = “albertosl@tag-id.com.co”;
    //userAccountEmail = “User”;
    ServiceAccountCredential credential = new ServiceAccountCredential(
    new ServiceAccountCredential.Initializer(serviceAccountEmail)
    {
    Scopes = new[] { DriveService.Scope.Drive, DriveService.Scope.DriveAppdata, DriveService.Scope.DriveAppsReadonly, DriveService.Scope.DriveFile, DriveService.Scope.DriveMetadata, DriveService.Scope.DriveMetadataReadonly, DriveService.Scope.DriveReadonly, DriveService.Scope.DriveScripts }
    ,
    User = userAccountEmail

    }.FromCertificate(certificate));

    // Create the service.
    var service = new DriveService(new BaseClientService.Initializer()
    {
    HttpClientInitializer = credential,
    ApplicationName = “devcoemmi”,
    });

    var listReq = service.Files.List();
    FileList files = listReq.Execute();
    tbFileCount.Text = files.Items.Count().ToString();

  • Sanjeev

    Still i am getting Error:”unauthorized_client”, Description:”Unauthorized client or scope in request.”, Uri:”” error. When i tried to use google drive API with my company domain(@mycompany.com) it is working fine. But when i tried to access it with my client domain it is giving above error. Can you please tell me the steps on how to resolve this issue.