Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8861837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:34:54+00:00 2026-06-14T15:34:54+00:00

I’d like to make an application that could access MY own Google Drive anytime,

  • 0

I’d like to make an application that could access MY own Google Drive anytime, create files there, share them and so on.
According to https://developers.google.com/drive/service-accounts “Use regular Google accounts as application-owned accounts” the only think I need is to get access_token and refresh_token once, store them in my application and using refresh_token I can refresh my access_token (somehow).

I can get access_token using request something like
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive.file&redirect_uri=http://localhost;response_type=token&client_id=

After approve this application request in user dialog I will be redirected to my localhost and I will get access_token that expires in 3600 seconds.

The questions are:

1. How to get a refresh_token?
2. How to refresh access_token using refresh_token?

I don’t want to use Google’s API client library because it’s terrible (.NET).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:34:55+00:00Added an answer on June 14, 2026 at 3:34 pm

    Ok I got it.
    The answer can be found here: https://developers.google.com/accounts/docs/OAuth2WebServer#offline

    First You have to make an Auth request

        <form method="POST" action="https://accounts.google.com/o/oauth2/auth">
            <input type="hidden" name="scope" value="[YOUR SCOPE]"/>
            <input type="hidden" name="client_id" value="[YOUR CLIENT ID]"/>
            <input type="hidden" name="response_type" value="code"/>
            <input type="hidden" name="redirect_uri" value="[YOUR RETURN URL]"/>
            <input type="hidden" name="access_type" value="offline"/>
            <input type="submit"/>
        </form>
    

    Then you will get a ‘code’ to your return_url

    Then you need to exchange the code to access_token and refresh_token

            <form method="POST" action="https://accounts.google.com/o/oauth2/token">
                <input type="text" name="code" value="[CODE YOU GOT IN PREV STEP]"/>
                <input type="hidden" name="client_id" value="[YOUR CLIENT ID]"/>
                <input type="hidden" name="client_secret" value="YOUR CLIENT SECRET"/>
                <input type="hidden" name="grant_type" value="authorization_code"/>
                <input type="hidden" name="redirect_uri" value="YOUR REDIRECT URL"/>
                <input type="submit"/>
            </form>
    

    As a result of this you will bet response like:

    {
      "access_token" : "[HERE YOU ACCESS TOKEN]",
      "token_type" : "Bearer",
      "expires_in" : 3600,
      "id_token" : "eyJhbGciOiJSUzI1NiIsImtpZCI6ImRiMjBlNWMwZGU1YWI0MGRjNTU5ODBkM2EzYmZlNDdlOGM2NGM5YjAifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiY2lkIjoiMjQ2ODg5NjU3NDg2LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiMjQ2ODg5NjU3NDg2LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwidG9rZW5faGFzaCI6IjRURGtlQ0MzVWRPZHoyd2k1N2RnaUEiLCJpZCI6IjExNTI0MDk1NDM0Njg1NTU4NjE2MSIsImlhdCI6MTM1MzQwNDQ3MCwiZXhwIjoxMzUzNDA4MzcwfQ.Va98sh9LvMEIWxpRMFkcuFqtDAUfJLN5M__oJyjvmIxQR9q2NUIoocyjqbNyXc7as_ePQYiUjajx0SCumtR4Zhv-exeJfrKA_uMmJTe7jWhK6K2R3JQ2-aIZNnehpEuhYZBXgLhzYz1mlFrLqQTdV6LjDhRPDH-ol4UKWXfbAVE",
      "refresh_token" : "[HERE YOUR REFRESH TOKEN]"
    }
    

    Now you can store these tokens in your application and use for unlimited time refreshing the access_token every 3600 secs

                <form method="POST" action="https://accounts.google.com/o/oauth2/token">
                    <input type="text" name="refresh_token" value="[YOUR REFRESH TOKEN]"/>
                    <input type="hidden" name="client_id" value="[YOUR CLIENT ID]"/>
                    <input type="hidden" name="client_secret" value="[YOUR CLIENT SECRET]"/>
                    <input type="hidden" name="grant_type" value="refresh_token"/>
                    <input type="submit"/>
                </form>
    

    And each time you make this request you will get a new access_token

    {
      "access_token" : "[NEW ACCESS TOKEN]",
      "token_type" : "Bearer",
      "expires_in" : 3600,
      "id_token" : "eyJhbGciOiJSUzI1NiIsImtpZCI6ImRiMjBlNWMwZGU1YWI0MGRjNTU5ODBkM2EzYmZlNDdlOGM2NGM5YjAifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXVkIjoiMjQ2ODg5NjU3NDg2LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwidG9rZW5faGFzaCI6ImpyYk5oNkRHZFN4Y0w5MUI5Q1hab2ciLCJpZCI6IjExNTI0MDk1NDM0Njg1NTU4NjE2MSIsImNpZCI6IjI0Njg4OTY1NzQ4Ni5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImlhdCI6MTM1MzQwNTU5OSwiZXhwIjoxMzUzNDA5NDk5fQ.mGN3EYOX75gPubr3TqWIOBkfq-o3JBXMXx4MbxEBGMSuPdJi7VTqZa4isyR-st-J5_wTtA-j8tVQYnDeZDxj5KpJ14FFQPKTtv_VI5kvuT55KyOmGu4yidciYoffJMISisr8NqiksbemaiYX900sRv6PmoTA6Nf6VtHgj3BZjWo"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.