AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AuthObserverInterface.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
19 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_AUTHOBSERVERINTERFACE_H_
20 #define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_AUTHOBSERVERINTERFACE_H_
21 
22 #include <ostream>
23 
24 namespace alexaClientSDK {
25 namespace avsCommon {
26 namespace sdkInterfaces {
27 
32 public:
34  enum class State {
38  REFRESHED,
40  EXPIRED,
45  };
46 
48  enum class Error {
50  SUCCESS,
52  UNKNOWN_ERROR,
54  AUTHORIZATION_FAILED,
56  UNAUTHORIZED_CLIENT,
58  SERVER_ERROR,
60  INVALID_REQUEST,
62  INVALID_VALUE,
64  AUTHORIZATION_EXPIRED,
66  UNSUPPORTED_GRANT_TYPE,
68  INVALID_CODE_PAIR,
70  AUTHORIZATION_PENDING,
72  SLOW_DOWN,
74  INTERNAL_ERROR,
76  INVALID_CBL_CLIENT_ID
77  };
78 
80  struct FullState {
83 
86 
88  FullState();
89 
96  FullState(
99  };
100 
104  virtual ~AuthObserverInterface() = default;
105 
115  virtual void onAuthStateChange(State newState, Error error) = 0;
116 };
117 
121 }
122 
126  state = pState;
127  error = pError;
128 }
129 
139  return lhs.state == rhs.state && lhs.error == rhs.error;
140 }
141 
149 inline std::ostream& operator<<(std::ostream& stream, const AuthObserverInterface::State& state) {
150  switch (state) {
152  return stream << "UNINITIALIZED";
154  return stream << "REFRESHED";
156  return stream << "EXPIRED";
158  return stream << "UNRECOVERABLE_ERROR";
160  return stream << "AUTHORIZING";
161  }
162  return stream << "Unknown AuthObserverInterface::State!: " << state;
163 }
164 
172 inline std::ostream& operator<<(std::ostream& stream, const AuthObserverInterface::Error& error) {
173  switch (error) {
175  return stream << "SUCCESS";
177  return stream << "UNKNOWN_ERROR";
179  return stream << "AUTHORIZATION_FAILED";
181  return stream << "UNAUTHORIZED_CLIENT";
183  return stream << "SERVER_ERROR";
185  return stream << "INVALID_REQUEST";
187  return stream << "INVALID_VALUE";
189  return stream << "AUTHORIZATION_EXPIRED";
191  return stream << "UNSUPPORTED_GRANT_TYPE";
193  return stream << "INVALID_CODE_PAIR";
195  return stream << "AUTHORIZATION_PENDING";
197  return stream << "SLOW_DOWN";
199  return stream << "INTERNAL_ERROR";
201  return stream << "INVALID_CBL_CLIENT_ID";
202  }
203  return stream << "Unknown AuthObserverInterface::Error!: " << error;
204 }
205 
206 } // namespace sdkInterfaces
207 } // namespace avsCommon
208 } // namespace alexaClientSDK
209 
210 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_AUTHOBSERVERINTERFACE_H_
The authorization code is invalid, expired, revoked, or was issued to a different client...
An unknown body containing no error field has been encountered.
std::ostream & operator<<(std::ostream &stream, const AudioInputProcessorObserverInterface::State &state)
Definition: AudioInputProcessorObserverInterface.h:86
avsCommon::sdkInterfaces::AuthObserverInterface::State state
The state.
Definition: AuthObserverInterface.h:82
State
The enum State describes the state of authorization.
Definition: AuthObserverInterface.h:34
virtual void onAuthStateChange(State newState, Error error)=0
Currently in the process of authorizing, such as requesting or refreshing a token.
bool operator==(const AuthObserverInterface::FullState &lhs, const AuthObserverInterface::FullState &rhs)
Definition: AuthObserverInterface.h:138
An aggregated structure to simplify working with State and Error.
Definition: AuthObserverInterface.h:80
Error
The enum Error encodes possible errors which may occur when changing state.
Definition: AuthObserverInterface.h:48
Authorization failed in a manner that cannot be corrected by retry.
avsCommon::sdkInterfaces::AuthObserverInterface::Error error
The error.
Definition: AuthObserverInterface.h:85
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
FullState()
Constructor.
Definition: AuthObserverInterface.h:118
Invalid code pair provided in Code-based linking token request.
The request is missing a required parameter, has an invalid value, or is otherwise improperly formed...
Client should slow down in the rate of requests polling for an access token.

AlexaClientSDK 1.25.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0