[go: nahoru, domu]

Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(275)
Delta Between Two Patch Sets: Src/GoogleApis.Auth.WinRT/OAuth2/GoogleWebAuthorizationBroker.cs
Issue 94340043: Issue 463: Provide a signout\logout method (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Left Patch Set: Created 10 years, 1 month ago
Right Patch Set: Gus' comments Created 10 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 Copyright 2013 Google Inc 2 Copyright 2013 Google Inc
3 3
4 Licensed under the Apache License, Version 2.0 (the "License"); 4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License. 5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at 6 You may obtain a copy of the License at
7 7
8 http://www.apache.org/licenses/LICENSE-2.0 8 http://www.apache.org/licenses/LICENSE-2.0
9 9
10 Unless required by applicable law or agreed to in writing, software 10 Unless required by applicable law or agreed to in writing, software
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 private static async Task<UserCredential> AuthorizeAsync(ClientSecrets c lientSecrets, 62 private static async Task<UserCredential> AuthorizeAsync(ClientSecrets c lientSecrets,
63 IEnumerable<string> scopes, string user, CancellationToken taskCance llationToken) 63 IEnumerable<string> scopes, string user, CancellationToken taskCance llationToken)
64 { 64 {
65 var initializer = new GoogleAuthorizationCodeFlow.Initializer 65 var initializer = new GoogleAuthorizationCodeFlow.Initializer
66 { 66 {
67 ClientSecrets = clientSecrets, 67 ClientSecrets = clientSecrets,
68 Scopes = scopes, 68 Scopes = scopes,
69 DataStore = new StroageDataStore() 69 DataStore = new StroageDataStore()
70 }; 70 };
71 71
72 var installedApp = new AuthorizationCodeWinRTInstalledApp(initialize r); 72 var installedApp = new AuthorizationCodeWinRTInstalledApp(new Google AuthorizationCodeFlow(initializer));
73 return await installedApp.AuthorizeAsync(user, taskCancellationToken ).ConfigureAwait(false); 73 return await installedApp.AuthorizeAsync(user, taskCancellationToken ).ConfigureAwait(false);
74 }
75
76 /// <summary>
77 /// Asynchronously reauthorizes the user. This method should be called i f the users want to authorize after·
78 /// they revoked the token.
79 /// </summary>
80 /// <param name="userCredential">The current user credential. Its <see c ref="UserCredential.Token"/> will be
81 /// updated. </param>
82 /// <param name="taskCancellationToken">Cancellation token to cancel an operation.</param>
83 public static async Task ReauthorizeAsync(UserCredential userCredential,
84 CancellationToken taskCancellationToken)
85 {
86 var installedApp = new AuthorizationCodeWinRTInstalledApp(userCreden tial.Flow);
87 // Create an authorization code installed app instance and authorize the user.
88 UserCredential newUserCredential = await installedApp.AuthorizeAsync (
89 userCredential.UderId, taskCancellationToken).ConfigureAwait(fal se);
90 userCredential.Token = newUserCredential.Token;
74 } 91 }
75 92
76 /// <summary>Loads the client secrets from the given URI.</summary> 93 /// <summary>Loads the client secrets from the given URI.</summary>
77 /// <param name="clientSecretsUri">The client secrets URI.</param> 94 /// <param name="clientSecretsUri">The client secrets URI.</param>
78 /// <returns>Client secrets.</returns> 95 /// <returns>Client secrets.</returns>
79 private static async Task<ClientSecrets> LoadClientSecrets(Uri clientSec retsUri) 96 private static async Task<ClientSecrets> LoadClientSecrets(Uri clientSec retsUri)
80 { 97 {
81 var file = await StorageFile.GetFileFromApplicationUriAsync(clientSe cretsUri); 98 var file = await StorageFile.GetFileFromApplicationUriAsync(clientSe cretsUri);
82 var content = await FileIO.ReadTextAsync(file); 99 var content = await FileIO.ReadTextAsync(file);
83 100
84 using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content) )) 101 using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content) ))
85 { 102 {
86 return GoogleClientSecrets.Load(stream).Secrets; 103 return GoogleClientSecrets.Load(stream).Secrets;
87 } 104 }
88 } 105 }
89 } 106 }
90 } 107 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b