cancel
Showing results for 
Search instead for 
Did you mean: 

Scope Authentication required for youtube API

0 Kudos

While using the youtube API to get the subscriptions,liked videos,upload videos and comments, and update the channel details of the authenticated user in our angular project using youtube APIs,we are getting 403 Forbidden error. It states that request had insufficient authentication scopes.

we have tried applying scope and access token to the API but still we get this error. Could any one help us with this error and provide suggestions based on it. Here I have attached the screenshot of the error message and our code.

Service.ts:

<code> import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { GoogleLoginProvider } from 'angularx-social-login';

@Injectable({
  providedIn: 'root'
})
export class YoutubeService {
  
  private APIURL = "https://youtube.googleapis.com/youtube/v3/";
  private APIKEY ="AIzaSyB40HaKwd0VggftBq8R9sEwQx_NG5xOOWc";
  SocialAuthService: any;
  access_token=localStorage.getItem('token');
  reqHeader:any;
  constructor(private http:HttpClient) {
    const reqHeader = new HttpHeaders().set('Authorization', 'Bearer ' + this.access_token)
    .set('Scope', 'https://www.googleapis.com/auth/youtube.readonly')
   }

  public GetSubscriptions()
  {
    return this.http.get("https://youtube.googleapis.com/youtube/v3/subscriptions?part=snippet%2CcontentDetails&mine=true&key=AIzaSyB40HaKwd0VggftBq8R9sEwQx_NG5xOOWc",this.reqHeader);
  }
 }
}

jerryjanda
Community Manager
Community Manager
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members. Feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will help you when submitting questions to the community. For example, you can make sure you've applied the appropriate tags (e.g., is this question related to SAP Hybris as a Service?). If you don't apply the correct tags, the right experts won't see your question to answer it.

Should you wish, you can revise your question by selecting Actions, then Edit.

The more details you provide, the more likely it is that members will be able to respond.

I also recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

Kind regards,

--Jerry

Moderation Lead

Accepted Solutions (0)

Answers (0)