2
我使用java(https://developers.google.com/drive/v2/web/quickstart/java)跟蹤Google Drive的API,並且存在以下代碼行,它在我的項目目錄(我將其複製)中包含client_id和client_secret的.json文件。如何在我的Java應用程序中硬編寫Google OAuth的client_id和client_secret?
// Load client secrets.
InputStream in = GoogleDrive.class.getResourceAsStream("client_id.json");
this.clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(DATA_STORE_FACTORY)
.setAccessType("offline")
.build();
我做了一個GoogleDrive.java類,使登錄,上傳等更容易。
我該如何硬編碼.json文件中的信息,並讓谷歌「加載」它到clientsecrets,以便我可以在其他應用程序中使用此類。我在REST是一個新手,所以一步一步的注意將不勝感激。
謝謝大家。