Youtube API request credentials





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







13















I created an python application that is using the Youtube api (so examples are in python, but doesn't really matter, the concepts should be the same). I managed to get it working where I can connect and make api calls. However, when I connect to the api, I have to define a flow that checks if a the credentials storage file exists. If it doesn't, then I have to manually sign in using the flow. After sign in the file (main.py-oauth2.json), is created with the token. I would like to be able to download the credentials without having to sign manually sign in. I was hoping there was a way to make a POST request for that token, like I have seen here, but I have been able to do this with Youtube api. Does anyone know how to implement the desired feature ?



main.py



flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE,
scope=YOUTUBE_UPLOAD_SCOPE,
message=MISSING_CLIENT_SECRETS_MESSAGE)
storage = Storage(OAUTH_CREDENTIALS)

credentials = storage.get()

if credentials is None or credentials.invalid:
# manual / UI login
credentials = run_flow(flow, storage, args)


Trying to use a google service account throws 401 errors on upload.



credentials = Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=YOUTUBE_UPLOAD_SCOPES)

if credentials is None or credentials.expired:
raise ValueError('Invalid credentials')

return build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
credentials=credentials)
...
status, response = insert_request.next_chunk()
# <HttpError 401 "Unauthorized">


Evidence this can be done




The oauth2client.service_account.ServiceAccountCredentials class is
only used with OAuth 2.0 Service Accounts. No end-user is involved
for these server-to-server API calls, so you can create this object
directly without using a Flow object.




youtube api
Oauth flow docs



https://developers.google.com/identity/protocols/OAuth2#serviceaccount










share|improve this question

























  • Are you pertaining about how to use the downloaded client_secrets.json?

    – jess
    Nov 29 '18 at 11:38











  • @jess, i don't believe so. From my understanding, the flow uses the client secrets to store the client api details, you still have to login to get a token. From what i have read here, developers.google.com/api-client-library/python/guide/aaa_oauth

    – AJ_
    Nov 29 '18 at 14:51











  • Yes you will still to login from your google account to generate client secrets from the console.

    – jess
    Nov 30 '18 at 10:47











  • Unfortunately, what you desire is not possible with the YouTube API. Specifically, the YouTube API does not support service account credentials. The closest thing you could do would be to create it like it's an 'installed' application, with a long-term token that you ask for, but that would still require at least one initial user sign in. See developers.google.com/youtube/v3/guides/… for more details.

    – jlmcdonald
    Dec 5 '18 at 6:34


















13















I created an python application that is using the Youtube api (so examples are in python, but doesn't really matter, the concepts should be the same). I managed to get it working where I can connect and make api calls. However, when I connect to the api, I have to define a flow that checks if a the credentials storage file exists. If it doesn't, then I have to manually sign in using the flow. After sign in the file (main.py-oauth2.json), is created with the token. I would like to be able to download the credentials without having to sign manually sign in. I was hoping there was a way to make a POST request for that token, like I have seen here, but I have been able to do this with Youtube api. Does anyone know how to implement the desired feature ?



main.py



flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE,
scope=YOUTUBE_UPLOAD_SCOPE,
message=MISSING_CLIENT_SECRETS_MESSAGE)
storage = Storage(OAUTH_CREDENTIALS)

credentials = storage.get()

if credentials is None or credentials.invalid:
# manual / UI login
credentials = run_flow(flow, storage, args)


Trying to use a google service account throws 401 errors on upload.



credentials = Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=YOUTUBE_UPLOAD_SCOPES)

if credentials is None or credentials.expired:
raise ValueError('Invalid credentials')

return build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
credentials=credentials)
...
status, response = insert_request.next_chunk()
# <HttpError 401 "Unauthorized">


Evidence this can be done




The oauth2client.service_account.ServiceAccountCredentials class is
only used with OAuth 2.0 Service Accounts. No end-user is involved
for these server-to-server API calls, so you can create this object
directly without using a Flow object.




youtube api
Oauth flow docs



https://developers.google.com/identity/protocols/OAuth2#serviceaccount










share|improve this question

























  • Are you pertaining about how to use the downloaded client_secrets.json?

    – jess
    Nov 29 '18 at 11:38











  • @jess, i don't believe so. From my understanding, the flow uses the client secrets to store the client api details, you still have to login to get a token. From what i have read here, developers.google.com/api-client-library/python/guide/aaa_oauth

    – AJ_
    Nov 29 '18 at 14:51











  • Yes you will still to login from your google account to generate client secrets from the console.

    – jess
    Nov 30 '18 at 10:47











  • Unfortunately, what you desire is not possible with the YouTube API. Specifically, the YouTube API does not support service account credentials. The closest thing you could do would be to create it like it's an 'installed' application, with a long-term token that you ask for, but that would still require at least one initial user sign in. See developers.google.com/youtube/v3/guides/… for more details.

    – jlmcdonald
    Dec 5 '18 at 6:34














13












13








13


1






I created an python application that is using the Youtube api (so examples are in python, but doesn't really matter, the concepts should be the same). I managed to get it working where I can connect and make api calls. However, when I connect to the api, I have to define a flow that checks if a the credentials storage file exists. If it doesn't, then I have to manually sign in using the flow. After sign in the file (main.py-oauth2.json), is created with the token. I would like to be able to download the credentials without having to sign manually sign in. I was hoping there was a way to make a POST request for that token, like I have seen here, but I have been able to do this with Youtube api. Does anyone know how to implement the desired feature ?



main.py



flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE,
scope=YOUTUBE_UPLOAD_SCOPE,
message=MISSING_CLIENT_SECRETS_MESSAGE)
storage = Storage(OAUTH_CREDENTIALS)

credentials = storage.get()

if credentials is None or credentials.invalid:
# manual / UI login
credentials = run_flow(flow, storage, args)


Trying to use a google service account throws 401 errors on upload.



credentials = Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=YOUTUBE_UPLOAD_SCOPES)

if credentials is None or credentials.expired:
raise ValueError('Invalid credentials')

return build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
credentials=credentials)
...
status, response = insert_request.next_chunk()
# <HttpError 401 "Unauthorized">


Evidence this can be done




The oauth2client.service_account.ServiceAccountCredentials class is
only used with OAuth 2.0 Service Accounts. No end-user is involved
for these server-to-server API calls, so you can create this object
directly without using a Flow object.




youtube api
Oauth flow docs



https://developers.google.com/identity/protocols/OAuth2#serviceaccount










share|improve this question
















I created an python application that is using the Youtube api (so examples are in python, but doesn't really matter, the concepts should be the same). I managed to get it working where I can connect and make api calls. However, when I connect to the api, I have to define a flow that checks if a the credentials storage file exists. If it doesn't, then I have to manually sign in using the flow. After sign in the file (main.py-oauth2.json), is created with the token. I would like to be able to download the credentials without having to sign manually sign in. I was hoping there was a way to make a POST request for that token, like I have seen here, but I have been able to do this with Youtube api. Does anyone know how to implement the desired feature ?



main.py



flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE,
scope=YOUTUBE_UPLOAD_SCOPE,
message=MISSING_CLIENT_SECRETS_MESSAGE)
storage = Storage(OAUTH_CREDENTIALS)

credentials = storage.get()

if credentials is None or credentials.invalid:
# manual / UI login
credentials = run_flow(flow, storage, args)


Trying to use a google service account throws 401 errors on upload.



credentials = Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=YOUTUBE_UPLOAD_SCOPES)

if credentials is None or credentials.expired:
raise ValueError('Invalid credentials')

return build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
credentials=credentials)
...
status, response = insert_request.next_chunk()
# <HttpError 401 "Unauthorized">


Evidence this can be done




The oauth2client.service_account.ServiceAccountCredentials class is
only used with OAuth 2.0 Service Accounts. No end-user is involved
for these server-to-server API calls, so you can create this object
directly without using a Flow object.




youtube api
Oauth flow docs



https://developers.google.com/identity/protocols/OAuth2#serviceaccount







python oauth-2.0 google-api youtube-api youtube-api-v3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 5 '18 at 2:27







AJ_

















asked Nov 29 '18 at 4:25









AJ_AJ_

91622254




91622254













  • Are you pertaining about how to use the downloaded client_secrets.json?

    – jess
    Nov 29 '18 at 11:38











  • @jess, i don't believe so. From my understanding, the flow uses the client secrets to store the client api details, you still have to login to get a token. From what i have read here, developers.google.com/api-client-library/python/guide/aaa_oauth

    – AJ_
    Nov 29 '18 at 14:51











  • Yes you will still to login from your google account to generate client secrets from the console.

    – jess
    Nov 30 '18 at 10:47











  • Unfortunately, what you desire is not possible with the YouTube API. Specifically, the YouTube API does not support service account credentials. The closest thing you could do would be to create it like it's an 'installed' application, with a long-term token that you ask for, but that would still require at least one initial user sign in. See developers.google.com/youtube/v3/guides/… for more details.

    – jlmcdonald
    Dec 5 '18 at 6:34



















  • Are you pertaining about how to use the downloaded client_secrets.json?

    – jess
    Nov 29 '18 at 11:38











  • @jess, i don't believe so. From my understanding, the flow uses the client secrets to store the client api details, you still have to login to get a token. From what i have read here, developers.google.com/api-client-library/python/guide/aaa_oauth

    – AJ_
    Nov 29 '18 at 14:51











  • Yes you will still to login from your google account to generate client secrets from the console.

    – jess
    Nov 30 '18 at 10:47











  • Unfortunately, what you desire is not possible with the YouTube API. Specifically, the YouTube API does not support service account credentials. The closest thing you could do would be to create it like it's an 'installed' application, with a long-term token that you ask for, but that would still require at least one initial user sign in. See developers.google.com/youtube/v3/guides/… for more details.

    – jlmcdonald
    Dec 5 '18 at 6:34

















Are you pertaining about how to use the downloaded client_secrets.json?

– jess
Nov 29 '18 at 11:38





Are you pertaining about how to use the downloaded client_secrets.json?

– jess
Nov 29 '18 at 11:38













@jess, i don't believe so. From my understanding, the flow uses the client secrets to store the client api details, you still have to login to get a token. From what i have read here, developers.google.com/api-client-library/python/guide/aaa_oauth

– AJ_
Nov 29 '18 at 14:51





@jess, i don't believe so. From my understanding, the flow uses the client secrets to store the client api details, you still have to login to get a token. From what i have read here, developers.google.com/api-client-library/python/guide/aaa_oauth

– AJ_
Nov 29 '18 at 14:51













Yes you will still to login from your google account to generate client secrets from the console.

– jess
Nov 30 '18 at 10:47





Yes you will still to login from your google account to generate client secrets from the console.

– jess
Nov 30 '18 at 10:47













Unfortunately, what you desire is not possible with the YouTube API. Specifically, the YouTube API does not support service account credentials. The closest thing you could do would be to create it like it's an 'installed' application, with a long-term token that you ask for, but that would still require at least one initial user sign in. See developers.google.com/youtube/v3/guides/… for more details.

– jlmcdonald
Dec 5 '18 at 6:34





Unfortunately, what you desire is not possible with the YouTube API. Specifically, the YouTube API does not support service account credentials. The closest thing you could do would be to create it like it's an 'installed' application, with a long-term token that you ask for, but that would still require at least one initial user sign in. See developers.google.com/youtube/v3/guides/… for more details.

– jlmcdonald
Dec 5 '18 at 6:34












1 Answer
1






active

oldest

votes


















5





+50









The problem is that most YouTube data is private user data. Being that it is private user data you must be authenticated as a user who has access to the data in question in order to access it. To do that we use Oauth2 and login to our account and get an access token and a refresh token returned.



The access token can be used to request data from the Youtube Api, the refresh token can be used to request a new access token when ever the access token expires (After an hour)



Normally i would say that you should consider using a service account. Services accounts are dummy users who can be preconfigured with access to user data. Unfortunately the Youtube api does not support service accounts.



What you should be doing and what i have done a number of times in the past is to authenticate your code once. Get the refresh token and save it. In the future whenever you wish to run your application you simply use the refresh token to request a new access token and you will be able to access the api. You wont have to manually type your login and password and consent to the access anymore everything can be done in the background using the refesh token.



Note: You will need to watch it there are some cases that can cause a refresh token to expire but you shouldn't worry for the most part they are good for as long as you continue to use them regularly.



I am not a python dev but found this



from oauth2client import client, GOOGLE_TOKEN_URI

CLIENT_ID = "client_id"
CLIENT_SECRET = "client_secret"
REFRESH_TOKEN = "refresh_token"


credentials = client.OAuth2Credentials(
access_token = None,
client_id = CLIENT_ID,
client_secret = CLIENT_SECRET,
refresh_token = REFRESH_TOKEN,
token_expiry = None,
token_uri = GOOGLE_TOKEN_URI,
token_ id = None,
revoke_uri= None)

http = credentials.authorize(httplib2.Http())





share|improve this answer
























  • Correct me if im wrong, but you have to create a flow, for a user to go through, to get the refresh token, do you know of a way to obtain a refresh token without having to use the google UI, or an automated function maybe?

    – AJ_
    Dec 5 '18 at 15:46













  • There isn't one you will need to have the user do that at least once then save the redirect URI. A user Will always have to login and click on the consent screen both are webpages

    – DaImTo
    Dec 5 '18 at 17:00











  • So there is no way to connect to the youtube account, with the google account associated with either the serve rice account, or the client api? i thought the docs explicitly say no end user is needed.

    – AJ_
    Dec 5 '18 at 17:32








  • 1





    You can't work around this a user must login and click the consent screen. This is the point of Oauth2. Google shut down client login in 2015 you can't use login and password. There is no way too automatically sign-in. You only need to do it once to get the refresh token I don't understand why that is a problem when it's your own account.

    – DaImTo
    Dec 5 '18 at 18:55






  • 1





    Again you dont need to login everytime. You need to login one single time save the refresh token. Everytime there after your code will use the refresh token to request an access token. You dont need to login again you dont need to click on anything again just ONCE, the first time. Not the second time, not the third time. Only the first time one time.

    – DaImTo
    Dec 5 '18 at 19:16














Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53531822%2fyoutube-api-request-credentials%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5





+50









The problem is that most YouTube data is private user data. Being that it is private user data you must be authenticated as a user who has access to the data in question in order to access it. To do that we use Oauth2 and login to our account and get an access token and a refresh token returned.



The access token can be used to request data from the Youtube Api, the refresh token can be used to request a new access token when ever the access token expires (After an hour)



Normally i would say that you should consider using a service account. Services accounts are dummy users who can be preconfigured with access to user data. Unfortunately the Youtube api does not support service accounts.



What you should be doing and what i have done a number of times in the past is to authenticate your code once. Get the refresh token and save it. In the future whenever you wish to run your application you simply use the refresh token to request a new access token and you will be able to access the api. You wont have to manually type your login and password and consent to the access anymore everything can be done in the background using the refesh token.



Note: You will need to watch it there are some cases that can cause a refresh token to expire but you shouldn't worry for the most part they are good for as long as you continue to use them regularly.



I am not a python dev but found this



from oauth2client import client, GOOGLE_TOKEN_URI

CLIENT_ID = "client_id"
CLIENT_SECRET = "client_secret"
REFRESH_TOKEN = "refresh_token"


credentials = client.OAuth2Credentials(
access_token = None,
client_id = CLIENT_ID,
client_secret = CLIENT_SECRET,
refresh_token = REFRESH_TOKEN,
token_expiry = None,
token_uri = GOOGLE_TOKEN_URI,
token_ id = None,
revoke_uri= None)

http = credentials.authorize(httplib2.Http())





share|improve this answer
























  • Correct me if im wrong, but you have to create a flow, for a user to go through, to get the refresh token, do you know of a way to obtain a refresh token without having to use the google UI, or an automated function maybe?

    – AJ_
    Dec 5 '18 at 15:46













  • There isn't one you will need to have the user do that at least once then save the redirect URI. A user Will always have to login and click on the consent screen both are webpages

    – DaImTo
    Dec 5 '18 at 17:00











  • So there is no way to connect to the youtube account, with the google account associated with either the serve rice account, or the client api? i thought the docs explicitly say no end user is needed.

    – AJ_
    Dec 5 '18 at 17:32








  • 1





    You can't work around this a user must login and click the consent screen. This is the point of Oauth2. Google shut down client login in 2015 you can't use login and password. There is no way too automatically sign-in. You only need to do it once to get the refresh token I don't understand why that is a problem when it's your own account.

    – DaImTo
    Dec 5 '18 at 18:55






  • 1





    Again you dont need to login everytime. You need to login one single time save the refresh token. Everytime there after your code will use the refresh token to request an access token. You dont need to login again you dont need to click on anything again just ONCE, the first time. Not the second time, not the third time. Only the first time one time.

    – DaImTo
    Dec 5 '18 at 19:16


















5





+50









The problem is that most YouTube data is private user data. Being that it is private user data you must be authenticated as a user who has access to the data in question in order to access it. To do that we use Oauth2 and login to our account and get an access token and a refresh token returned.



The access token can be used to request data from the Youtube Api, the refresh token can be used to request a new access token when ever the access token expires (After an hour)



Normally i would say that you should consider using a service account. Services accounts are dummy users who can be preconfigured with access to user data. Unfortunately the Youtube api does not support service accounts.



What you should be doing and what i have done a number of times in the past is to authenticate your code once. Get the refresh token and save it. In the future whenever you wish to run your application you simply use the refresh token to request a new access token and you will be able to access the api. You wont have to manually type your login and password and consent to the access anymore everything can be done in the background using the refesh token.



Note: You will need to watch it there are some cases that can cause a refresh token to expire but you shouldn't worry for the most part they are good for as long as you continue to use them regularly.



I am not a python dev but found this



from oauth2client import client, GOOGLE_TOKEN_URI

CLIENT_ID = "client_id"
CLIENT_SECRET = "client_secret"
REFRESH_TOKEN = "refresh_token"


credentials = client.OAuth2Credentials(
access_token = None,
client_id = CLIENT_ID,
client_secret = CLIENT_SECRET,
refresh_token = REFRESH_TOKEN,
token_expiry = None,
token_uri = GOOGLE_TOKEN_URI,
token_ id = None,
revoke_uri= None)

http = credentials.authorize(httplib2.Http())





share|improve this answer
























  • Correct me if im wrong, but you have to create a flow, for a user to go through, to get the refresh token, do you know of a way to obtain a refresh token without having to use the google UI, or an automated function maybe?

    – AJ_
    Dec 5 '18 at 15:46













  • There isn't one you will need to have the user do that at least once then save the redirect URI. A user Will always have to login and click on the consent screen both are webpages

    – DaImTo
    Dec 5 '18 at 17:00











  • So there is no way to connect to the youtube account, with the google account associated with either the serve rice account, or the client api? i thought the docs explicitly say no end user is needed.

    – AJ_
    Dec 5 '18 at 17:32








  • 1





    You can't work around this a user must login and click the consent screen. This is the point of Oauth2. Google shut down client login in 2015 you can't use login and password. There is no way too automatically sign-in. You only need to do it once to get the refresh token I don't understand why that is a problem when it's your own account.

    – DaImTo
    Dec 5 '18 at 18:55






  • 1





    Again you dont need to login everytime. You need to login one single time save the refresh token. Everytime there after your code will use the refresh token to request an access token. You dont need to login again you dont need to click on anything again just ONCE, the first time. Not the second time, not the third time. Only the first time one time.

    – DaImTo
    Dec 5 '18 at 19:16
















5





+50







5





+50



5




+50





The problem is that most YouTube data is private user data. Being that it is private user data you must be authenticated as a user who has access to the data in question in order to access it. To do that we use Oauth2 and login to our account and get an access token and a refresh token returned.



The access token can be used to request data from the Youtube Api, the refresh token can be used to request a new access token when ever the access token expires (After an hour)



Normally i would say that you should consider using a service account. Services accounts are dummy users who can be preconfigured with access to user data. Unfortunately the Youtube api does not support service accounts.



What you should be doing and what i have done a number of times in the past is to authenticate your code once. Get the refresh token and save it. In the future whenever you wish to run your application you simply use the refresh token to request a new access token and you will be able to access the api. You wont have to manually type your login and password and consent to the access anymore everything can be done in the background using the refesh token.



Note: You will need to watch it there are some cases that can cause a refresh token to expire but you shouldn't worry for the most part they are good for as long as you continue to use them regularly.



I am not a python dev but found this



from oauth2client import client, GOOGLE_TOKEN_URI

CLIENT_ID = "client_id"
CLIENT_SECRET = "client_secret"
REFRESH_TOKEN = "refresh_token"


credentials = client.OAuth2Credentials(
access_token = None,
client_id = CLIENT_ID,
client_secret = CLIENT_SECRET,
refresh_token = REFRESH_TOKEN,
token_expiry = None,
token_uri = GOOGLE_TOKEN_URI,
token_ id = None,
revoke_uri= None)

http = credentials.authorize(httplib2.Http())





share|improve this answer













The problem is that most YouTube data is private user data. Being that it is private user data you must be authenticated as a user who has access to the data in question in order to access it. To do that we use Oauth2 and login to our account and get an access token and a refresh token returned.



The access token can be used to request data from the Youtube Api, the refresh token can be used to request a new access token when ever the access token expires (After an hour)



Normally i would say that you should consider using a service account. Services accounts are dummy users who can be preconfigured with access to user data. Unfortunately the Youtube api does not support service accounts.



What you should be doing and what i have done a number of times in the past is to authenticate your code once. Get the refresh token and save it. In the future whenever you wish to run your application you simply use the refresh token to request a new access token and you will be able to access the api. You wont have to manually type your login and password and consent to the access anymore everything can be done in the background using the refesh token.



Note: You will need to watch it there are some cases that can cause a refresh token to expire but you shouldn't worry for the most part they are good for as long as you continue to use them regularly.



I am not a python dev but found this



from oauth2client import client, GOOGLE_TOKEN_URI

CLIENT_ID = "client_id"
CLIENT_SECRET = "client_secret"
REFRESH_TOKEN = "refresh_token"


credentials = client.OAuth2Credentials(
access_token = None,
client_id = CLIENT_ID,
client_secret = CLIENT_SECRET,
refresh_token = REFRESH_TOKEN,
token_expiry = None,
token_uri = GOOGLE_TOKEN_URI,
token_ id = None,
revoke_uri= None)

http = credentials.authorize(httplib2.Http())






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 5 '18 at 12:49









DaImToDaImTo

47.1k1168249




47.1k1168249













  • Correct me if im wrong, but you have to create a flow, for a user to go through, to get the refresh token, do you know of a way to obtain a refresh token without having to use the google UI, or an automated function maybe?

    – AJ_
    Dec 5 '18 at 15:46













  • There isn't one you will need to have the user do that at least once then save the redirect URI. A user Will always have to login and click on the consent screen both are webpages

    – DaImTo
    Dec 5 '18 at 17:00











  • So there is no way to connect to the youtube account, with the google account associated with either the serve rice account, or the client api? i thought the docs explicitly say no end user is needed.

    – AJ_
    Dec 5 '18 at 17:32








  • 1





    You can't work around this a user must login and click the consent screen. This is the point of Oauth2. Google shut down client login in 2015 you can't use login and password. There is no way too automatically sign-in. You only need to do it once to get the refresh token I don't understand why that is a problem when it's your own account.

    – DaImTo
    Dec 5 '18 at 18:55






  • 1





    Again you dont need to login everytime. You need to login one single time save the refresh token. Everytime there after your code will use the refresh token to request an access token. You dont need to login again you dont need to click on anything again just ONCE, the first time. Not the second time, not the third time. Only the first time one time.

    – DaImTo
    Dec 5 '18 at 19:16





















  • Correct me if im wrong, but you have to create a flow, for a user to go through, to get the refresh token, do you know of a way to obtain a refresh token without having to use the google UI, or an automated function maybe?

    – AJ_
    Dec 5 '18 at 15:46













  • There isn't one you will need to have the user do that at least once then save the redirect URI. A user Will always have to login and click on the consent screen both are webpages

    – DaImTo
    Dec 5 '18 at 17:00











  • So there is no way to connect to the youtube account, with the google account associated with either the serve rice account, or the client api? i thought the docs explicitly say no end user is needed.

    – AJ_
    Dec 5 '18 at 17:32








  • 1





    You can't work around this a user must login and click the consent screen. This is the point of Oauth2. Google shut down client login in 2015 you can't use login and password. There is no way too automatically sign-in. You only need to do it once to get the refresh token I don't understand why that is a problem when it's your own account.

    – DaImTo
    Dec 5 '18 at 18:55






  • 1





    Again you dont need to login everytime. You need to login one single time save the refresh token. Everytime there after your code will use the refresh token to request an access token. You dont need to login again you dont need to click on anything again just ONCE, the first time. Not the second time, not the third time. Only the first time one time.

    – DaImTo
    Dec 5 '18 at 19:16



















Correct me if im wrong, but you have to create a flow, for a user to go through, to get the refresh token, do you know of a way to obtain a refresh token without having to use the google UI, or an automated function maybe?

– AJ_
Dec 5 '18 at 15:46







Correct me if im wrong, but you have to create a flow, for a user to go through, to get the refresh token, do you know of a way to obtain a refresh token without having to use the google UI, or an automated function maybe?

– AJ_
Dec 5 '18 at 15:46















There isn't one you will need to have the user do that at least once then save the redirect URI. A user Will always have to login and click on the consent screen both are webpages

– DaImTo
Dec 5 '18 at 17:00





There isn't one you will need to have the user do that at least once then save the redirect URI. A user Will always have to login and click on the consent screen both are webpages

– DaImTo
Dec 5 '18 at 17:00













So there is no way to connect to the youtube account, with the google account associated with either the serve rice account, or the client api? i thought the docs explicitly say no end user is needed.

– AJ_
Dec 5 '18 at 17:32







So there is no way to connect to the youtube account, with the google account associated with either the serve rice account, or the client api? i thought the docs explicitly say no end user is needed.

– AJ_
Dec 5 '18 at 17:32






1




1





You can't work around this a user must login and click the consent screen. This is the point of Oauth2. Google shut down client login in 2015 you can't use login and password. There is no way too automatically sign-in. You only need to do it once to get the refresh token I don't understand why that is a problem when it's your own account.

– DaImTo
Dec 5 '18 at 18:55





You can't work around this a user must login and click the consent screen. This is the point of Oauth2. Google shut down client login in 2015 you can't use login and password. There is no way too automatically sign-in. You only need to do it once to get the refresh token I don't understand why that is a problem when it's your own account.

– DaImTo
Dec 5 '18 at 18:55




1




1





Again you dont need to login everytime. You need to login one single time save the refresh token. Everytime there after your code will use the refresh token to request an access token. You dont need to login again you dont need to click on anything again just ONCE, the first time. Not the second time, not the third time. Only the first time one time.

– DaImTo
Dec 5 '18 at 19:16







Again you dont need to login everytime. You need to login one single time save the refresh token. Everytime there after your code will use the refresh token to request an access token. You dont need to login again you dont need to click on anything again just ONCE, the first time. Not the second time, not the third time. Only the first time one time.

– DaImTo
Dec 5 '18 at 19:16






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53531822%2fyoutube-api-request-credentials%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks