Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.14.2...main), [Documentation](https://swiftpackageindex.com/parse-community/Parse-Swift/main/documentation/parseswift)
* _Contributing to this repo? Add info about your change here to be included in the next release_

__New features__
- Add ParseWeibo authentication ([#466](https://github.com/parse-community/Parse-Swift/pull/466)), thanks to [Moe Kanan](https://github.com/mohkg1017).

### 4.14.2
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.14.1...4.14.2), [Documentation](https://swiftpackageindex.com/parse-community/Parse-Swift/4.14.2/documentation/parseswift)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
//
// ParseWeibo+async.swift
// ParseSwift
//
// Created by Moe Kanan on 5/12/26.
// Copyright © 2026 Parse Community. All rights reserved.
//

#if compiler(>=5.5.2) && canImport(_Concurrency)
import Foundation

public extension ParseWeibo {
// MARK: Async/Await

/**
Login a `ParseUser` *asynchronously* using secure Weibo authentication.
- parameter code: The authorization code from Weibo.
- parameter redirectURI: The redirect URI registered for Weibo.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: An error of type `ParseError`.
*/
func login(code: String,
redirectURI: String,
options: API.Options = []) async throws -> AuthenticatedUser {
try await withCheckedThrowingContinuation { continuation in
self.login(code: code,
redirectURI: redirectURI,
options: options,
completion: continuation.resume)
}
}

/**
Login a `ParseUser` *asynchronously* using deprecated insecure Weibo authentication.
- parameter id: The id from Weibo.
- parameter accessToken: The access token from Weibo.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: An error of type `ParseError`.
*/
func login(id: String,
accessToken: String,
options: API.Options = []) async throws -> AuthenticatedUser {
try await withCheckedThrowingContinuation { continuation in
self.login(id: id,
accessToken: accessToken,
options: options,
completion: continuation.resume)
}
}

/**
Login a `ParseUser` *asynchronously* using Weibo authentication.
- parameter authData: Dictionary containing key/values.
- returns: An instance of the logged in `ParseUser`.
- throws: An error of type `ParseError`.
*/
func login(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
try await withCheckedThrowingContinuation { continuation in
self.login(authData: authData,
options: options,
completion: continuation.resume)
}
}
}

public extension ParseWeibo {

/**
Link the *current* `ParseUser` *asynchronously* using secure Weibo authentication.
- parameter code: The authorization code from Weibo.
- parameter redirectURI: The redirect URI registered for Weibo.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: An error of type `ParseError`.
*/
func link(code: String,
redirectURI: String,
options: API.Options = []) async throws -> AuthenticatedUser {
try await withCheckedThrowingContinuation { continuation in
self.link(code: code,
redirectURI: redirectURI,
options: options,
completion: continuation.resume)
}
}

/**
Link the *current* `ParseUser` *asynchronously* using deprecated insecure Weibo authentication.
- parameter id: The id from Weibo.
- parameter accessToken: The access token from Weibo.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: An error of type `ParseError`.
*/
func link(id: String,
accessToken: String,
options: API.Options = []) async throws -> AuthenticatedUser {
try await withCheckedThrowingContinuation { continuation in
self.link(id: id,
accessToken: accessToken,
options: options,
completion: continuation.resume)
}
}

/**
Link the *current* `ParseUser` *asynchronously* using Weibo authentication.
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: An error of type `ParseError`.
*/
func link(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
try await withCheckedThrowingContinuation { continuation in
self.link(authData: authData,
options: options,
completion: continuation.resume)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
//
// ParseWeibo+combine.swift
// ParseSwift
//
// Created by Moe Kanan on 5/12/26.
// Copyright © 2026 Parse Community. All rights reserved.
//

#if canImport(Combine)
import Foundation
import Combine

public extension ParseWeibo {
// MARK: Combine
/**
Login a `ParseUser` *asynchronously* using secure Weibo authentication. Publishes when complete.
- parameter code: The authorization code from Weibo.
- parameter redirectURI: The redirect URI registered for Weibo.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(code: String,
redirectURI: String,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(code: code,
redirectURI: redirectURI,
options: options,
completion: promise)
}
}

/**
Login a `ParseUser` *asynchronously* using deprecated insecure Weibo authentication. Publishes when complete.
- parameter id: The id from Weibo.
- parameter accessToken: The access token from Weibo.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(id: String,
accessToken: String,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(id: id,
accessToken: accessToken,
options: options,
completion: promise)
}
}

/**
Login a `ParseUser` *asynchronously* using Weibo authentication. Publishes when complete.
- parameter authData: Dictionary containing key/values.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(authData: [String: String],
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(authData: authData,
options: options,
completion: promise)
}
}
}

public extension ParseWeibo {
/**
Link the *current* `ParseUser` *asynchronously* using secure Weibo authentication. Publishes when complete.
- parameter code: The authorization code from Weibo.
- parameter redirectURI: The redirect URI registered for Weibo.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(code: String,
redirectURI: String,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(code: code,
redirectURI: redirectURI,
options: options,
completion: promise)
}
}

/**
Link the *current* `ParseUser` *asynchronously* using deprecated insecure Weibo authentication. Publishes when complete.
- parameter id: The id from Weibo.
- parameter accessToken: The access token from Weibo.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(id: String,
accessToken: String,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(id: id,
accessToken: accessToken,
options: options,
completion: promise)
}
}

/**
Link the *current* `ParseUser` *asynchronously* using Weibo authentication. Publishes when complete.
- parameter authData: Dictionary containing key/values.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(authData: [String: String],
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(authData: authData,
options: options,
completion: promise)
}
}
}
#endif
Loading