Go to the Google APIs Console and select your App Engine project. One-time setup to enable Google Drive for your Google App Engine project I recently had to implement something similar, and it is quite tricky to find the relevant pieces of documentation. However, where am I supposed to get authorisation_code from? Raise NoRefreshTokenException(authorization_url) Logging.error('No user ID could be retrieved.')Īuthorization_url = get_authorization_url(email_address, state) # If none is available, redirect the user to the authorization URL.Įthorization_url = get_authorization_url(email_address, state) # Drive apps should try to retrieve the user and credentials for the current Logging.error('An error occurred during code exchange.') If credentials and credentials.refresh_token is not None: If credentials.refresh_token is not None:Ĭredentials = get_stored_credentials(user_id) NoRefreshTokenException: No refresh token could be retrieved from theĬredentials = exchange_code(authorization_code) 2Credentials instance containing an access andĬodeExchangeError: Could not exchange the authorization code. State: State to set to the authorization URL in case of error. With the authorization URL to redirect the user to.Īuthorization_code: Authorization code to use to retrieve an access token. If no refresh token has been retrieved, the function checks in the applicationĭatabase for one and returns it if found or raises a NoRefreshTokenException In the application database using the user's e-mail address as key. If a refresh token has been retrieved along with an access token, it is stored The UserInfo API to retrieve the user's e-mail address. This function exchanges the authorization code for an access token and queries """Retrieve credentials using the provided authorization code. If you take a look at this function: def get_credentials(authorization_code, state): I have tried looking at the google drive api, and the problem is that I don't know where to start with the following boilerplate code located in their documentation. Note that, my account owns both the drive and the app engine page. I have a google app engine site, and what I want to do, is get access to the files on my drive and publish them.
0 Comments
Leave a Reply. |